【问题标题】:Resolving Python package version conflict in Reddit install解决 Reddit 安装中的 Python 包版本冲突
【发布时间】:2013-06-14 03:23:29
【问题描述】:

我正在尝试在我的 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 脚本,但我还没有掌握它们。

【问题讨论】:

    标签: python python-2.7 reddit


    【解决方案1】:

    问题出在 WebTest 库的版本为 2.0.6。这个版本需要 WebOb>=1.2。

    确定python模块的要求。我 cd 进入虚拟环境的站点包目录,然后运行:

    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 运行,但至少我删除了这个块。

    【讨论】:

      【解决方案2】:

      Reddit 的安装程序 addsUbuntu private package repository。 PPA 包括许多 Ubuntu python 包的变体。

      如果您运行的是 Ubuntu,您也可以安装 PPA。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-01-23
        • 2015-07-02
        • 2018-10-26
        • 2019-10-30
        • 2019-07-27
        • 1970-01-01
        • 2016-05-26
        相关资源
        最近更新 更多