Partage
  • Partager sur Facebook
  • Partager sur Twitter

Virtualenv (cours Ansible)

Dépréciation de Python 2.7

    6 mars 2021 à 12:55:03

    Bonjour,

    J'espère poster au bon endroit, si ce n'est pas le cas soyez indulgents s'il vous plaît je suis nouveau sur Open Classrooms.

    J'utilise un Raspberry Pi4 avec installation récente (mars 2021) de Raspberry OS basé sur Debian 10.8 (Raspbian GNU/Linux 10 (buster)).

    Je suis nouveau sur Linux et je suis le cours sur Ansible "Utilisez Ansible pour automatiser vos tâches de configuration" et je suis bloqué dès son chapitre 2 "Installez Ansible dans votre environnement".

    Je parviens à installer "virtualenv" via "apt install python-virtualenv" et à m'y connecter via "source ansible2.7.10/bin/activate".

    C'est l'étape suivante qui envoie beaucoup d'erreurs : "pip install ansible==2.7.10".

    Je suis désolé pour cette présentation immonde mais je ne comprends pas quelles balises utiliser (markdown ou BBCode ou HTML), j'essaierai de faire mieux la prochaine fois.

    Il semblerait donc que le cours ne soit pas à jour malgré une date annoncée de janvier 2021.

    Un message principal (mis ci-dessous parce que je ne comprends pas comment mettre en évidence un morceau de code et le reste des écrits était moche).

    De plus, l'installation échoue avec le message extrêmement long recopié ci-dessous.

    Comme il s'agit du début du cours et que tout reposera dessus, je ne sais pas comment me débrouiller avec ceci.

    Comment faire pour contacter la personne qui a écrit le cours (Alexandre DOMONT) pour qu'il puisse modifier son cours pour utiliser un virtualenv non déprécié ?

    Note : j'ai essayé de désinstaller vitrualenv et d'installer "apt install python3-virtualenv" mais là aussi en lançant la commande pip il part sur Python 2.7...

    Merci par avance pour votre aide et votre indulgence !   

    Message principal :

    `DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.`   

    <secret>Collecting cryptography
      Using cached cryptography-3.3.2.tar.gz (539 kB)
      Installing build dependencies ... error
      ERROR: Command errored out with exit status 1:
       command: /home/ansible/ansible2.7.10/bin/python2 /home/ansible/ansible2.7.10/local/lib/python2.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-kMCd6f/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.12; platform_python_implementation != '"'"'PyPy'"'"''
           cwd: None
      Complete output (142 lines):
      DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
      Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple, https://www.piwheels.org/simple
      Collecting setuptools>=40.6.0
        Using cached setuptools-44.1.1-py2.py3-none-any.whl (583 kB)
      Collecting wheel
        Using cached wheel-0.36.2-py2.py3-none-any.whl (35 kB)
      Collecting cffi>=1.12
        Using cached cffi-1.14.5.tar.gz (475 kB)
      Collecting pycparser
        Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
      Building wheels for collected packages: cffi
        Building wheel for cffi (setup.py): started
        Building wheel for cffi (setup.py): finished with status 'error'
        ERROR: Command errored out with exit status 1:
         command: /home/ansible/ansible2.7.10/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-NCZ4EV/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-NCZ4EV/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-me60MU
             cwd: /tmp/pip-install-NCZ4EV/cffi/
        Complete output (56 lines):
        Package libffi was not found in the pkg-config search path.
        Perhaps you should add the directory containing `libffi.pc'
        to the PKG_CONFIG_PATH environment variable
        No package 'libffi' found
        Package libffi was not found in the pkg-config search path.
        Perhaps you should add the directory containing `libffi.pc'
        to the PKG_CONFIG_PATH environment variable
        No package 'libffi' found
        Package libffi was not found in the pkg-config search path.
        Perhaps you should add the directory containing `libffi.pc'
        to the PKG_CONFIG_PATH environment variable
        No package 'libffi' found
        Package libffi was not found in the pkg-config search path.
        Perhaps you should add the directory containing `libffi.pc'
        to the PKG_CONFIG_PATH environment variable
        No package 'libffi' found
        Package libffi was not found in the pkg-config search path.
        Perhaps you should add the directory containing `libffi.pc'
        to the PKG_CONFIG_PATH environment variable
        No package 'libffi' found
        running bdist_wheel
        running build
        running build_py
        creating build
        creating build/lib.linux-armv7l-2.7
        creating build/lib.linux-armv7l-2.7/cffi
        copying cffi/vengine_cpy.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/model.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/setuptools_ext.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/error.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/cffi_opcode.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/backend_ctypes.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/api.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/__init__.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/ffiplatform.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/pkgconfig.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/cparser.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/vengine_gen.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/verifier.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/lock.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/recompiler.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/commontypes.py -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/_cffi_include.h -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/parse_c_type.h -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/_embedding.h -> build/lib.linux-armv7l-2.7/cffi
        copying cffi/_cffi_errors.h -> build/lib.linux-armv7l-2.7/cffi
        running build_ext
        building '_cffi_backend' extension
        creating build/temp.linux-armv7l-2.7
        creating build/temp.linux-armv7l-2.7/c
        arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-InigCj/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-armv7l-2.7/c/_cffi_backend.o
        c/_cffi_backend.c:15:10: fatal error: ffi.h: Aucun fichier ou dossier de ce type
         #include <ffi.h>
                  ^~~~~~~
        compilation terminated.
        error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
        ----------------------------------------
        ERROR: Failed building wheel for cffi
        Running setup.py clean for cffi
      Failed to build cffi
      Installing collected packages: setuptools, wheel, pycparser, cffi
          Running setup.py install for cffi: started
          Running setup.py install for cffi: finished with status 'error'
          ERROR: Command errored out with exit status 1:
           command: /home/ansible/ansible2.7.10/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-NCZ4EV/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-NCZ4EV/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-fkBkRW/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-kMCd6f/overlay --compile --install-headers /tmp/pip-build-env-kMCd6f/overlay/include/site/python2.7/cffi
               cwd: /tmp/pip-install-NCZ4EV/cffi/
          Complete output (56 lines):
          Package libffi was not found in the pkg-config search path.
          Perhaps you should add the directory containing `libffi.pc'
          to the PKG_CONFIG_PATH environment variable
          No package 'libffi' found
          Package libffi was not found in the pkg-config search path.
          Perhaps you should add the directory containing `libffi.pc'
          to the PKG_CONFIG_PATH environment variable
          No package 'libffi' found
          Package libffi was not found in the pkg-config search path.
          Perhaps you should add the directory containing `libffi.pc'
          to the PKG_CONFIG_PATH environment variable
          No package 'libffi' found
          Package libffi was not found in the pkg-config search path.
          Perhaps you should add the directory containing `libffi.pc'
          to the PKG_CONFIG_PATH environment variable
          No package 'libffi' found
          Package libffi was not found in the pkg-config search path.
          Perhaps you should add the directory containing `libffi.pc'
          to the PKG_CONFIG_PATH environment variable
          No package 'libffi' found
          running install
          running build
          running build_py
          creating build
          creating build/lib.linux-armv7l-2.7
          creating build/lib.linux-armv7l-2.7/cffi
          copying cffi/vengine_cpy.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/model.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/setuptools_ext.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/error.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/cffi_opcode.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/backend_ctypes.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/api.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/__init__.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/ffiplatform.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/pkgconfig.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/cparser.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/vengine_gen.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/verifier.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/lock.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/recompiler.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/commontypes.py -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/_cffi_include.h -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/parse_c_type.h -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/_embedding.h -> build/lib.linux-armv7l-2.7/cffi
          copying cffi/_cffi_errors.h -> build/lib.linux-armv7l-2.7/cffi
          running build_ext
          building '_cffi_backend' extension
          creating build/temp.linux-armv7l-2.7
          creating build/temp.linux-armv7l-2.7/c
          arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-InigCj/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-armv7l-2.7/c/_cffi_backend.o
          c/_cffi_backend.c:15:10: fatal error: ffi.h: Aucun fichier ou dossier de ce type
           #include <ffi.h>
                    ^~~~~~~
          compilation terminated.
          error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
          ----------------------------------------
      ERROR: Command errored out with exit status 1: /home/ansible/ansible2.7.10/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-NCZ4EV/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-NCZ4EV/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-fkBkRW/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-kMCd6f/overlay --compile --install-headers /tmp/pip-build-env-kMCd6f/overlay/include/site/python2.7/cffi Check the logs for full command output.
      ----------------------------------------
    ERROR: Command errored out with exit status 1: /home/ansible/ansible2.7.10/bin/python2 /home/ansible/ansible2.7.10/local/lib/python2.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-kMCd6f/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.12; platform_python_implementation != '"'"'PyPy'"'"'' Check the logs for full command output.
    </secret>

    -
    Edité par Delvekior 6 mars 2021 à 13:03:12

    • Partager sur Facebook
    • Partager sur Twitter
      3 juin 2021 à 0:32:17

      as tu regardé la doc d'ansible au moins ?

      faut utiliser python3

      https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html

      • Partager sur Facebook
      • Partager sur Twitter
        3 juin 2021 à 17:06:26

        Tu as sans doute un lien symbolique qui pointe vers Python 2 alors que ansible requiert python 3....Donc peut être le lien symbolique python->python 2.7 est à mettre en python->3.x

        Certains programmes utilisent encore python 2 c'est pour ça que par défaut ça doit être comme ça.

        • Partager sur Facebook
        • Partager sur Twitter
          16 août 2021 à 17:12:17

          Bonjour,

          Je post un peu en retard par rapport à ce topic mais bon, mieux vaut tard que jamais et puis vu que c'est posé là, ça pourrait servir à d'autres personnes...

          Donc voici comment je m'y suis pris

          Installe les paquets suivants:

          *  epel-release

          *  python3.9

          *  python3-virtualenv

          Ensuite mets python3.9 par défaut comme suit:

          sudo alternatives   --set python   /usr/bin/python3.9
          sudo alternatives   --set python3   /usr/bin/python3.9

          Et enfin crée ton environnent virtuel en précisant la bonne version de python comme ceci:


          virtualenv-3.6 -p /usr/bin/python3.9 ansible2.11.3

          Avec ça et après vérification (ansible --version), tu devrais avoir ansible avec la bonne version de python et tu ne devrais plus avoir les messages de dépréciation

          -
          Edité par Camar67 16 août 2021 à 17:13:46

          • Partager sur Facebook
          • Partager sur Twitter
            2 septembre 2021 à 4:47:35

            Si par défaut votre système fait pointer python vers python2 c'est qu'il doit malheureusement avoir ses raisons. Le modifier pourrait nuire à son fonctionnement.

            Donc vous devriez laisser le lien python par défaut et préciser la version que vous voulez utiliser comme vous le faite par la suite.

            • Partager sur Facebook
            • Partager sur Twitter

            Virtualenv (cours Ansible)

            × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
            × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
            • Editeur
            • Markdown