gpt4 book ai didi

python - 解决 Reddit 安装中的 Python 包版本冲突

转载 作者:太空狗 更新时间:2023-10-30 02:47:07 30 4
gpt4 key购买 nike

我正在尝试在我的 Mac 上安装 Reddit 的 Python 库。我想使用 PyCharm 来运行它们进行开发,因为我喜欢它作为 Python IDE。

我在 Virtual Box 实例中运行 Cassandra、Memcached、RabbitMQ 和 Postgres 服务器,该实例可通过 Virtual Box Host-only 适配器访问。这是可行的,因为我可以在 Virtual Box 中启动 Reddit 并从我的 Mac 访问它。

当运行粘贴脚本以查看 Reddit Python 源安装是否在 Mac 上运行时。我收到以下错误:

    Traceback (most recent call last):
File "/Users/inflector/software/new-day/reddit/dev/bin/paster", line 8, in <module>
load_entry_point('PasteScript==1.7.5', 'console_scripts', 'paster')()
File "/Users/inflector/software/new-day/reddit/dev/lib/python2.7/site-packages/paste/script/command.py", line 93, in run
commands = get_commands()
File "/Users/inflector/software/new-day/reddit/dev/lib/python2.7/site-packages/paste/script/command.py", line 135, in get_commands
plugins = pluginlib.resolve_plugins(plugins)
File "/Users/inflector/software/new-day/reddit/dev/lib/python2.7/site-packages/paste/script/pluginlib.py", line 82, in resolve_plugins
pkg_resources.require(plugin)
File "build/bdist.linux-i686/egg/pkg_resources.py", line 666, in require
File "build/bdist.linux-i686/egg/pkg_resources.py", line 569, in resolve
pkg_resources.VersionConflict: (WebOb 1.2.3 (/Users/inflector/software/new-day/reddit/dev/lib/python2.7/site-packages), Requirement.parse('webob==1.0.8'))

如果我将安装降级到 WebOb 1.0.8,我得到相反的结果,它需要 'WebOb>=1.2'。

“pip list”显示安装了这些包:

amqplib (1.0.2)
Babel (0.9.6)
bcrypt (1.0.2)
Beaker (1.6.4)
BeautifulSoup (3.2.1)
beautifulsoup4 (4.2.1)
boto (2.9.5)
cffi (0.6)
chardet (2.1.1)
crypto (1.1.0)
cssutils (0.9.5.1)
Cython (0.19.1)
decorator (3.4.0)
FormEncode (1.2.6)
kazoo (1.1)
l2cs (2.0.2)
lxml (3.2.1)
Mako (0.8.1)
MarkupSafe (0.18)
nose (1.3.0)
Paste (1.7.5.1)
PasteDeploy (1.5.0)
PasteScript (1.7.5)
PIL (1.1.7)
psycopg2 (2.5)
py-bcrypt (0.3)
pyasn1 (0.1.7)
PyCAPTCHA (0.4)
pycassa (1.9.0)
pycountry (0.14.8)
pycparser (2.09.1)
pycrypto (2.6)
Pygments (1.6)
pylibmc (1.2.3)
Pylons (0.9.7)
pytz (2013b)
repoze.lru (0.6)
requests (1.2.3)
Routes (1.11)
rsa (3.1.1)
simplejson (3.3.0)
six (1.3.0)
snudown (1.1.5)
SQLAlchemy (0.7.4)
stripe (1.9.1)
Tempita (0.5.1)
thrift (0.9.0)
waitress (0.8.5)
WebError (0.10.3)
WebHelpers (1.3)
WebOb (1.2.3)
WebTest (2.0.6)
Whoosh (2.4.1)
wsgiref (0.1.2)
zope.interface (4.0.5)

我的假设是这些包中至少有一个需要 WebOb==1.0.8 并且至少有一个其他包需要 WebOb>=1.2

我已经为 Reddit 安装设置了一个 virtualenv,并使用 --no-site-packages 选项进行设置,这样我就只处理 Reddit 所需的包。我手动安装了我认为需要的一切。所以这实际上是最小的包集。我需要它们中的每一个,但也许不是所有的都是正确的版本。 Reddit 安装程序不会为每个包指定版本,只会指定其中的一些版本。

那么我该如何追踪这些依赖关系呢?如何获取 virtualenv 中安装的每个软件包的要求列表?

文件“build/bdist.linux-i686/egg/pkg_resources.py”来自哪里?我无法在我的系统中的任何地方找到它。而且 Mac 不是 Linux,所以这看起来很奇怪。

我是一个非常有经验的程序员,C++、Java、Object Pascal、Objective C 等等,但还不是专家级的 Python 程序员。所以在这一点上,Python 包系统对我来说太像一个黑盒子了。我可以使用 pip 并运行 setup.py 脚本,但我还没有理解它们。

最佳答案

问题来自 WebTest 库的 2.0.6 版。此版本是要求 WebOb>=1.2 的版本。

确定 python 模块的要求。我 cd 到虚拟环境的 site-packages 目录然后运行:

grep WebOb *.egg-info/requires.txt

返回:

Pylons-0.9.7-py2.7.egg-info/requires.txt:WebOb>=0.9.6.1
WebError-0.10.3-py2.7.egg-info/requires.txt:WebOb
WebTest-2.0.6-py2.7.egg-info/requires.txt:WebOb>=1.2

在那里我可以看到 WebTest 是有冲突的包。

然后我可以进入我的 Ubuntu 安装,查看安装了什么 WebTest 包,发现 WebTest 1.3.3 可以在标准的 Ubuntu Reddit 安装上运行。所以我卸载了 WebOb 1.2 和 WebTest 2.0.6 然后运行:

pip install webob==1.0.8
pip install webtest==1.3.3

这消除了冲突 WebOb 版本冲突。我仍然无法让 Reddit 运行,但至少我删除了这个 block 。

关于python - 解决 Reddit 安装中的 Python 包版本冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17159961/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com