gpt4 book ai didi

python - Python打包模块的版本冲突问题

转载 作者:行者123 更新时间:2023-11-28 17:19:58 31 4
gpt4 key购买 nike

我正在使用 stack.sh 部署 OpenStack Newton devstack

我遇到了以下问题:

Processing /opt/stack/requirements
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-2UrvLp-build/setup.py", line 29, in <module>
pbr=True)
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/opt/stack/requirements/.venv/local/lib/python2.7/site-packages/setuptools/dist.py", line 320, in __init__
_Distribution.__init__(self, attrs)
File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/opt/stack/requirements/.venv/local/lib/python2.7/site-packages/setuptools/dist.py", line 386, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/opt/stack/requirements/.venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2318, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)
File "/opt/stack/requirements/.venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 859, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (packaging 16.7 (/opt/stack/requirements/.venv/lib/python2.7/site-packages), Requirement.parse('packaging>=16.8'))

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-2UrvLp-build/
+inc/python:pip_install:1 exit_trap
+./stack.sh:exit_trap:487 local r=1
++./stack.sh:exit_trap:488 jobs -p
+./stack.sh:exit_trap:488 jobs=
+./stack.sh:exit_trap:491 [[ -n '' ]]
+./stack.sh:exit_trap:497 kill_spinner
+./stack.sh:kill_spinner:383 '[' '!' -z '' ']'
+./stack.sh:exit_trap:499 [[ 1 -ne 0 ]]
+./stack.sh:exit_trap:500 echo 'Error on exit'
Error on exit
+./stack.sh:exit_trap:501 generate-subunit 1486635146 55 fail
+./stack.sh:exit_trap:502 [[ -z /opt/stack/logs ]]
+./stack.sh:exit_trap:505 /home/demo/devstack/tools/worlddump.py -d /opt/stack/logs
World dumping... see /opt/stack/logs/worlddump-2017-02-09-101322.txt for details
+./stack.sh:exit_trap:511 exit 1

看起来名为“packaging”的包存在版本冲突。

这是我所做的 -> 尝试通过执行以下操作卸载并重新安装软件包:

pip uninstall packaging

pip install --upgrade packaging

但这并没有真正帮助我,我又遇到了同样的错误。

请帮我解决这个问题,请具体说明我应该在哪个目录下执行哪个命令。

最佳答案

我在 devstack 中遇到了完全相同的错误,以下是修复方法:

首先添加一个全局设置来记录 pip 所做的一切。使用以下内容创建 /etc/pip.conf:

[global]
log = /var/log/pip.log

然后运行:

sudo touch /var/log/pip.log
sudo chmod a+rw /var/log/pip.log

确保 pip 始终可以写入此文件。

然后观察与打包包相关的变化:

tail -f /var/log/pip.log |grep packaging

同时重新启动 ./stack.sh

在某些时候,在 pip 日志中您应该看到类似于以下的行:

Setting packaging===16.7 (from -c /opt/stack/requirements/upper-constraints.txt ...

这向您显示了此要求的来源,在本例中它来自 /opt/stack/requirements/upper-constraints.txt 文件。

然后您可以手动编辑有问题的文件来更改此要求以消除冲突。就我而言,我更换了:

packaging===16.7

通过

packaging>=16.8

/opt/stack/requirements/upper-constraints.txt

之后,devstack 安装顺利完成。


长话短说

cd /opt/stack/requirements/
sed -i.bak s/packaging===16.7/packaging>=16.8/g upper-contraints.txt

关于python - Python打包模块的版本冲突问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42140729/

31 4 0
文章推荐: javascript - jQuery - 隐藏 中的最后一个子