Ansible无法完成,因为已弃用Python,即使已安装Python 3

2024-10-04 11:31:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在试着从谷歌运行LaunchKit来获取一些应用程序截图。我已经完成了GitHub页面(https://github.com/LaunchKit/LaunchKit)上的所有开放源代码步骤。完成所有步骤并运行$ vagrant up --provision后,我得到以下结果:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty64' version '20190514.0.0' is up to date...
==> default: Running provisioner: ansible...
Vagrant has automatically selected the compatibility mode '2.0'
according to the Ansible version installed (2.9.2).

Alternatively, the compatibility mode can be specified in your Vagrantfile:
https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode

    default: Running ansible-playbook...

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [default]

TASK [update apt cache] ********************************************************
ok: [default]

TASK [common : install the unzip tool] *****************************************
ok: [default]

TASK [common : install launchkit dummy service] ********************************
ok: [default]

TASK [common : install vagrant start bug workaround] ***************************
ok: [default]

TASK [common-python : install python dev library] ******************************
ok: [default]

TASK [common-python : install packages for pip crypto] *************************
ok: [default]

TASK [common-python : install packages for ssl] ********************************
ok: [default]

TASK [common-python : install pip] *********************************************
ok: [default]

TASK [common-python : install python virtualenv] *******************************
ok: [default]

TASK [redis : install redis] ***************************************************
ok: [default]

TASK [redis : install redis config] ********************************************
ok: [default]

TASK [postgres : install postgres] *********************************************
ok: [default]

TASK [postgres : install postgres contrib] *************************************
ok: [default]

TASK [postgres : install postgres dev libraries] *******************************
ok: [default]

TASK [postgres : install postgres python library for further ansible configuration] ***
ok: [default]

TASK [postgres : install postgres config] **************************************
ok: [default]

TASK [postgres : install postgres security config] *****************************
ok: [default]

TASK [postgres : install postgres upstart service translation] *****************
ok: [default]

TASK [postgres : add local user as postgres superuser] *************************
ok: [default]

TASK [lk-django : install python lxml library] *********************************
ok: [default]

TASK [lk-django : install jpeg library for pillow] *****************************
ok: [default]

TASK [lk-django : install jpeg-dev library for pillow] *************************
ok: [default]

TASK [lk-django : install db adapter] ******************************************
ok: [default]

TASK [lk-django : upgrade pip] *************************************************
ok: [default]

TASK [lk-django : install python requirements] *********************************
fatal: [default]: FAILED! => {"changed": false, "cmd": ["/usr/local/bin/pip2", "install", "-r", "/vagrant/requirements.txt"], 
"msg": "stdout: Requirement already satisfied: boto==2.38.0 in /usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 1)) (2.38.0)\nRequirement already satisfied:
 celery[redis]==3.1.17 in /usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 2)) (3.1.17)\nRequirement already satisfied: cssutils==1.0.1
 in /usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 3)) (1.0.1)\nRequirement already satisfied: django-bitfield==1.7.1 in /usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 4)) (1.7.1)\nRequirement already satisfied:
 Django==1.7.3 in /usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 5)) (1.7.3)\nRequirement already satisfied: djorm-pgarray==1.2.0 in 
/usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 6)) (1.2)\nRequirement already satisfied: dnspython==1.12.0 in /usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 7)) (1.12.0)\nRequirement already satisfied:
 fabric==1.10.1 in /usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 8)) (1.10.1)\nRequirement already satisfied: hiredis==0.1.5 in /usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 9)) (0.1.5)\nRequirement already satisfied: Pillow==3.0.0 in /usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 10)) (3.0.0)\nRequirement already satisfied: premailer==1.3.0 in /usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 11)) (1.3.0)\nRequirement already satisfied: psycopg2==2.5.4 in 
/usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 12)) (2.5.4)\nRequirement already satisfied: pycrypto==2.6.1 in /usr/lib/python2.7/dist-packages 
(from -r /vagrant/requirements.txt (line 13)) (2.6.1)\nRequirement already satisfied: pylint==0.28.0 in /usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 14)) (0.28.0)\nRequirement already satisfied: python-memcached==1.53 in 
/usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 15)) (1.53)\nRequirement already satisfied: redis==2.10.3 in /usr/local/lib/python2.7/dist-packages (from -r /vagrant/requirements.txt (line 16)) (2.10.3)\nCollecting requests==2.5.3\n  Using cached https://files.pythonhosted.org/packages/95/54/44dc83b5f11c6da06bf9abd18c8a0905e0e297e0a9c3bfbc0c6ee4bdd33d/requests-2.5.3-py2.py3-none-any.whl\nProcessing 
/root/.cache/pip/wheels/59/10/55/80c2bd162c923de93fbec8237cdceeb795507da2748926850e/SQLAlchemy-0.9.8-cp27-none-linux_x86_64.whl\nCollecting tweepy==3.3.0\n  Using cached https://files.pythonhosted.org/packages/cd/8b/dfeeb1057d37af810161f8206aa5a6e6e9351dd87ea6f84e4f87d7e3c8a3/tweepy-3.3.0-py2.py3-none-any.whl\nProcessing 
/root/.cache/pip/wheels/1f/ea/0a/599a5398012b4e42f32cdfa9101fe35697d3df97282e1da5f3/ua_parser-0.3.6-cp27-none-any.whl\nRequirement already satisfied: billiard<3.4,>=3.3.0.19 in /usr/local/lib/python2.7/dist-packages (from celery[redis]==3.1.17->-r /vagrant/requirements.txt
 (line 2)) (3.3.0.23)\nRequirement already satisfied: pytz>dev in /usr/local/lib/python2.7/dist-packages (from celery[redis]==3.1.17->-r /vagrant/requirements.txt (line 2)) (2019.3)\nRequirement already satisfied: kombu<3.1,>=3.0.24 in /usr/local/lib/python2.7/dist-packages (from celery[redis]==3.1.17->-r /vagrant/requirements.txt (line 2)) 
(3.0.37)\nRequirement already satisfied: six in /usr/lib/python2.7/dist-packages (from django-bitfield==1.7.1->-r /vagrant/requirements.txt (line 4)) (1.5.2)\nRequirement already satisfied: paramiko>=1.10 in /usr/local/lib/python2.7/dist-packages (from fabric==1.10.1->-r 
/vagrant/requirements.txt (line 8)) (2.7.1)\nRequirement already satisfied: cssselect in /usr/local/lib/python2.7/dist-packages (from premailer==1.3.0->-r /vagrant/requirements.txt (line 11)) (1.1.0)\nRequirement already satisfied: lxml in /usr/lib/python2.7/dist-packages (from premailer==1.3.0->-r /vagrant/requirements.txt (line 11)) (3.3.3)\nRequirement already satisfied
: logilab-common>=0.53.0 in /usr/local/lib/python2.7/dist-packages (from pylint==0.28.0->-r /vagrant/requirements.txt (line 14)) (1.4.4)\nRequirement already satisfied: logilab-astng>=0.24.3 in /usr/local/lib/python2.7/dist-packages (from pylint==0.28.0->-r 
/vagrant/requirements.txt (line 14)) (0.24.3)\nCollecting requests-oauthlib>=0.4.1\n  Using cached 
https://files.pythonhosted.org/packages/a3/12/b92740d845ab62ea4edf04d2f4164d82532b5a0b03836d4d4e71c6f3d379/requests_oauthlib-1.3.0-py2.py3-none-any.whl\nRequirement already satisfied: anyjson>=0.3.3 in /usr/local/lib/python2.7/dist-packages (from kombu<3.1,>=3.0.24->celery[redis]==3.1.17->-r /vagrant/requirements.txt (line 2)) (0.3.3)\nRequirement already satisfied: amqp<2.0,>=1.4.9 in /usr/local/lib/python2.7/dist-packages (from kombu<3.1,>=3.0.24->celery[redis]==3.1.17->-r /vagrant/requirements.txt (line 2)) (1.4.9)\nRequirement already satisfied: bcrypt>=3.1.3 in /usr/local/lib/python2.7/dist-packages (from paramiko>=1.10->fabric==1.10.1->-r /vagrant/requirements.txt (line 8)) (3.1.7)\nRequirement already satisfied: cryptography>=2.5 in /usr/local/lib/python2.7/dist-packages (from paramiko>=1.10->fabric==1.10.1->-r /vagrant/requirements.txt (line 8)) (2.8)\nRequirement already satisfied: pynacl>=1.0.1 in /usr/local/lib/python2.7/dist-packages (from paramiko>=1.10->fabric==1.10.1->-r /vagrant/requirements.txt (line 8)) (1.3.0)\nRequirement already satisfied: setuptools in /usr/lib/python2.7/dist-packages (from logilab-common>=0.53.0->pylint==0.28.0->-r /vagrant/requirements.txt (line 14)) (3.3)\nCollecting oauthlib>=3.0.0\n  Using cached https://files.pythonhosted.org/packages/05/57/ce2e7a8fa7c0afb54a0581b14a65b56e62b5759dbc98e80627142b8a3704/oauthlib-3.1.0-py2.py3-none-any.whl\nRequirement already satisfied: cffi>=1.1 in /usr/local/lib/python2.7/dist-packages (from bcrypt>=3.1.3->paramiko>=1.10->fabric==1.10.1->-r /vagrant/requirements.txt (line 8)) (1.13.2)\nRequirement already satisfied: enum34; python_version < \"3\" in /usr/local/lib/python2.7/dist-packages (from cryptography>=2.5->paramiko>=1.10->fabric==1.10.1->-r /vagrant/requirements.txt (line 8)) (1.1.6)\nRequirement already satisfied: ipaddress; python_version < \"3\" in /usr/local/lib/python2.7/dist-packages (from cryptography>=2.5->paramiko>=1.10->fabric==1.10.1->-r /vagrant/requirements.txt (line 8)) (1.0.23)\nRequirement already satisfied: pycparser in /usr/local/lib/python2.7/dist-packages (from cffi>=1.1->bcrypt>=3.1.3->paramiko>=1.10->fabric==1.10.1->-r /vagrant/requirements.txt (line 8)) (2.19)\nInstalling collected packages: requests, sqlalchemy, oauthlib, requests-oauthlib, tweepy, ua-parser\n  
Found existing installation: requests 2.2.1\n\n:stderr: /usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/constant_time.py:26: CryptographyDeprecationWarning:
 Support for your Python version is deprecated. The next version of cryptography will remove support. Please upgrade to a release (2.7.7+) that supports hmac.compare_digest as soon as possible.\n  utils.PersistentlyDeprecated2018,\nDEPRECATION: 
Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for
 Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support\n/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/util/ssl_.py:380: 
SNIMissingWarning: An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS
 certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-
usage.html#ssl-warnings\n  SNIMissingWarning,\n/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/util/ssl_.py:139: InsecurePlatformWarning: A true SSLContext object
 is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more
 information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n  InsecurePlatformWarning,\nERROR: tweepy 3.3.0 has requirement six>=1.7.3, but you'll have six
 1.5.2 which is incompatible.\nERROR: Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only
 a partial uninstall.\n"}

PLAY RECAP *********************************************************************
default                    : ok=25   changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

Python2的当前版本是2.7.10(高于2.7.7+it请求),我还安装了python3(3.7.6)

这是我第一次在终端上深入研究这个问题

我还尝试为python=python3创建一个别名,但在调用vagrant up-provision时,它似乎仍在运行Python2

有没有办法解决这个问题


Tags: infromtxtdefaultlibpackagesusrlocal
1条回答
网友
1楼 · 发布于 2024-10-04 11:31:43

TASK [lk-django : install python requirements] ********************************* fatal: [default]: FAILED! => {"changed": false, "cmd": ["/usr/local/bin/pip2", "install", "-r", "/vagrant/requirements.txt"], ... ERROR: tweepy 3.3.0 has requirement six>=1.7.3, but you'll have six 1.5.2 which is incompatible.ERROR: Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.\n"}

手动卸载冲突包six 1.5.2


有可能Use Python 3 on the managed machines with commands and playbooks。如果您认为这将解决冲突,请在清单中设置变量ansible_python_interpreter

ansible_python_interpreter=/usr/bin/python3

应自动选择pip版本。该问题由pip报告。见source code

- name: install python requirements
  pip: requirements=/vagrant/requirements.txt

皮普说:

By default, it uses the pip version for the Ansible Python interpreter. For example, pip3 on python 3, and pip2 or pip on python 2.

相关问题 更多 >