使用Ansible pip模块安装python包的问题

时间:2015-09-06 08:10:09

标签: pip ansible pypi

当我尝试使用其pip模块安装Ansible的python包时,我正面临一些有趣的伏都教。

这里...... 如果我试试这个:

$ 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

提前感谢所有帮助者。

1 个答案:

答案 0 :(得分:2)

好的,我明白发生了什么。

问题是我的pip.conf文件仅供我的用户使用(在/home/user/.pip/pip.conf下)

我把它移到/etc/pip.conf并解决了问题。

添加到参数--trusted-host host的替代解决方案 我使用旧版本的pip很长一段时间,当我升级到最新版本时,我忘了更新参数。

干杯!

相关问题