在执行我的任务(nephelaiio.pyenv)之前,我已经有venv
我只想在现有的venv中安装需求。
这是我的角色的代码:
- name: Install project interpreter libraries
pip:
executable: "/home/int/.pyenv/versions/int-3.7.3/bin/pip"
requirements: "/home/int/int/requirements.txt"
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_pip_payload_38mr2d/__main__.py", line 254, in <module>
from pkg_resources import Requirement
ImportError: No module named pkg_resources
fatal: [my.host.com]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"chdir": null,
"editable": false,
"executable": "/home/int/.pyenv/versions/int-3.7.3/bin/pip",
"extra_args": null,
"name": null,
"requirements": "/home/int/int/requirements.txt",
"state": "present",
"umask": null,
"use_mirrors": true,
"version": null,
"virtualenv": null,
"virtualenv_command": "virtualenv",
"virtualenv_python": null,
"virtualenv_site_packages": false
}
},
"msg": "Failed to import the required Python library (setuptools) on debian's Python /usr/bin/python. Please read module documentation and install in the appropriate location"
}
-
int@my.host.com:~$ ls -al /home/int/int/requirements.txt
-rw-r--r-- 1 int int 110 Aug 28 09:59 /home/int/int/requirements.txt
int@my.host.com:~$ ls -al /home/int/.pyenv/versions/int-3.7.3/bin/pip
-rwxr-xr-x 1 int int 259 Aug 28 10:41 /home/int/.pyenv/versions/int-3.7.3/bin/pip
int@my.host.com:~$ whereis pip
pip: /home/int/.pyenv/shims/pip /home/int/.pyenv/shims/pip3.7
requirements.txt有数据
按路径点是可行的
ansible 2.8,debian 10
更新:似乎可以通过“ sudo apt install python-pip”修复它。
是正确的决定吗?
Update2:我的问题- 我错过了pip ansible模块的需求块。
答案 0 :(得分:3)
“ msg”:“无法在debian的Python / usr / bin / python上导入所需的Python库( setuptools )。请阅读模块文档并安装在适当的位置”
从模块文档pip中读取要求
执行此模块的主机需要满足以下要求。
要解决此问题,请在执行此模块的远程主机中安装 setuptools
。例如在Ubuntu
$ dpkg -l '*setuptools*'
ii python-setuptools 39.0.1-2
ii python3-setuptools 39.0.1-2
或FreeBSD
$ pkg info | grep setuptools
py27-setuptools-40.8.0 Python packages installer
py36-setuptools-40.8.0 Python packages installer