使用 Ansible pip 模块安装 python 包的问题
Issues with installation of python packages with Ansible pip module
当我尝试使用它的 pip 模块安装 python 包 Ansible
时,我遇到了一些有趣的问题。
这里...
如果我试试这个:
$ sudo pip install sh
sh
软件包安装成功,完全没有错误。
这是一件好事。
我将撤消此操作:
$ sudo pip uninstall sh
接下来我要尝试使用 Ansible
:
$ ansible smith pip -a 'name=sh state=present extra_args="-i http://host:port/simple"' -i inventory
这失败了。错误消息如下(请原谅我,但我在无法访问互联网的防火墙下工作,所以我不得不输入它。我过滤了我认为不需要的东西 - 如果仍然缺少某些东西,请告诉我,我会更新我的问题):
smith | FAILED >> {
"cmd" "/usr/local/bin/pip install -i http://host:port/simple sh",
...
msg: stdout: Collecting sh
Downloading http://host:port/packages/sh-1.09.tar.gz
...
running install
running build
running build_py
creating build
creating build/lib.linux-i686-2.7
copying sh.py -> build/lib.linux-i686-2.7
running install_lib
copying buikd/lib.linux-i686-2.7/sh.py -> /usr/local/lib/python2.7/dist-packages
error: /usr/local/lib/python2.7/dist-packages/sh.py: Permission denied
---------
:stderr: Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-zH3cTB/sh/setup.py' ... -- compile: failed with error code 1 in /tmp/pip-build-zH3cTB/sh
当然,我在最后一个命令中添加了--sudo
:
$ ansible smith -m pip -a 'name=sh state=present extra_args="-i http://host:port/simple"' -i inventory --sudo
这次我无语了。又失败了:
smith | FAILED >> {
"cmd" "/usr/local/bin/pip install -i http://host:port/simple sh",
...
msg: stdout: Collecting sh
Could not find a version that satisfied the requirement (from versions: ) No matching distribution found for sh
很奇怪。
这适用于我尝试安装的所有 python 个软件包。
附加信息:
我们有一个 pypi 服务器,我们将所有要安装的包都放在那里。
它在 host:port/simple
下
我们也使用这个 pip.conf
文件:
[global]
index-url = http://host:port/simple
trusted-host = host
提前感谢所有帮助者。
好的,我明白是怎么回事了。
问题是我的 pip.conf 文件仅供我的用户使用(在 /home/user/.pip/pip.conf
下)
我把它移到/etc/pip.conf 问题解决了。
另一种解决方案是添加参数 --trusted-host host
我使用旧版本的 pip 很长时间,当我升级到最新版本时忘记更新参数。
干杯!
当我尝试使用它的 pip 模块安装 python 包 Ansible
时,我遇到了一些有趣的问题。
这里... 如果我试试这个:
$ sudo pip install sh
sh
软件包安装成功,完全没有错误。
这是一件好事。
我将撤消此操作:
$ sudo pip uninstall sh
接下来我要尝试使用 Ansible
:
$ ansible smith pip -a 'name=sh state=present extra_args="-i http://host:port/simple"' -i inventory
这失败了。错误消息如下(请原谅我,但我在无法访问互联网的防火墙下工作,所以我不得不输入它。我过滤了我认为不需要的东西 - 如果仍然缺少某些东西,请告诉我,我会更新我的问题):
smith | FAILED >> {
"cmd" "/usr/local/bin/pip install -i http://host:port/simple sh",
...
msg: stdout: Collecting sh
Downloading http://host:port/packages/sh-1.09.tar.gz
...
running install
running build
running build_py
creating build
creating build/lib.linux-i686-2.7
copying sh.py -> build/lib.linux-i686-2.7
running install_lib
copying buikd/lib.linux-i686-2.7/sh.py -> /usr/local/lib/python2.7/dist-packages
error: /usr/local/lib/python2.7/dist-packages/sh.py: Permission denied
---------
:stderr: Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-zH3cTB/sh/setup.py' ... -- compile: failed with error code 1 in /tmp/pip-build-zH3cTB/sh
当然,我在最后一个命令中添加了--sudo
:
$ ansible smith -m pip -a 'name=sh state=present extra_args="-i http://host:port/simple"' -i inventory --sudo
这次我无语了。又失败了:
smith | FAILED >> {
"cmd" "/usr/local/bin/pip install -i http://host:port/simple sh",
...
msg: stdout: Collecting sh
Could not find a version that satisfied the requirement (from versions: ) No matching distribution found for sh
很奇怪。 这适用于我尝试安装的所有 python 个软件包。
附加信息:
我们有一个 pypi 服务器,我们将所有要安装的包都放在那里。
它在 host:port/simple
我们也使用这个 pip.conf
文件:
[global]
index-url = http://host:port/simple
trusted-host = host
提前感谢所有帮助者。
好的,我明白是怎么回事了。
问题是我的 pip.conf 文件仅供我的用户使用(在 /home/user/.pip/pip.conf
下)
我把它移到/etc/pip.conf 问题解决了。
另一种解决方案是添加参数 --trusted-host host
我使用旧版本的 pip 很长时间,当我升级到最新版本时忘记更新参数。
干杯!