Python virtualenv pip install MySQL-Python 导致“RuntimeError:超出最大递归深度”

Posted

技术标签:

【中文标题】Python virtualenv pip install MySQL-Python 导致“RuntimeError:超出最大递归深度”【英文标题】:Python virtualenv pip install MySQL-Python causing "RuntimeError: maximum recursion depth exceeded" 【发布时间】:2014-05-02 23:29:18 【问题描述】:

我设置了一个 virtualenv,然后尝试使用 pip (after activating env) 安装 mysql-Python。我的requirements.txt如下:

MySQL-python==1.2.5
argparse==1.2.1
pymongo==2.6.3
wsgiref==0.1.2

当我运行pip install -r requirement.txt 时。我得到一些输出,最后一行是:

RuntimeError: maximum recursion depth exceeded

正如一篇文章中提到的,我什至运行了这个命令来升级我的分发:

easy_install distribute==0.6.28

即使这样也没有用。我的 python 版本(在 env 中)是 2.7.6,机器是 Ubuntu 14.04


更新:堆栈跟踪如下:

Downloading/unpacking MySQL-python==1.2.5 (from -r requirements.txt (line 1))
  Running setup.py (path:/root/frrole_backend_raw_dump/env/build/MySQL-python/setup.py) egg_info for package MySQL-python
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/root/frrole_backend_raw_dump/env/build/MySQL-python/setup.py", line 21, in <module>
        setuptools.setup(**metadata)
      File "/usr/lib/python2.7/distutils/core.py", line 112, in setup
        _setup_distribution = dist = klass(attrs)
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 225, in __init__
      File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
        self.finalize_options()
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 257, in finalize_options
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2029, in require
        self.name = name
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 580, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 825, in best_match
        ``installer(requirement)``, unless `installer` is None, in which case
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 837, in obtain
        def __iadd__(self, other):
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 272, in fetch_build_egg
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 225, in __init__
      File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
        self.finalize_options()
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 257, in finalize_options
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2029, in require
        self.name = name
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 580, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 825, in best_match
        ``installer(requirement)``, unless `installer` is None, in which case
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 837, in obtain
        def __iadd__(self, other):
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 272, in fetch_build_egg
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 225, in __init__
      File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
        self.finalize_options()
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 257, in finalize_options
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2029, in require
        self.name = name
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 580, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 825, in best_match
        ``installer(requirement)``, unless `installer` is None, in which case
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 837, in obtain
        def __iadd__(self, other):
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 272, in fetch_build_egg
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 225, in __init__
      File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
        self.finalize_options()
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 257, in finalize_options
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2029, in require
        self.name = name
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 580, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)

【问题讨论】:

请发布完整的回溯。 我看到了完全相同的问题。 @BurhanKhalid 因为它是一个无限循环,所以大部分回溯只是上述内容。我会让 OP 编辑​​问题以添加它的尾部。 【参考方案1】:

也得到这个!

我的设置中的一些注意事项:

Ubuntu 13.10 Python-MySQLdb 和 libmysqlclient-dev 都是通过 apt-get 安装的

我也看到了这个,我怀疑这是根本原因:

x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-Qunused-arguments’
x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-Qunused-arguments’

编辑:

看起来我仍然得到这个(MySQL-Python 1.2.4),没有设置 CFLAGS 或 CPPFLAGS 环境变量。 1.2.5 适合我

【讨论】:

lolol,觉得这些标志看起来很熟悉 :) 我的问题是我在 Mac 上按照this thread 对我的 .bashrc 进行的修改。我从那台机器上复制了我的 .bashrc。

以上是关于Python virtualenv pip install MySQL-Python 导致“RuntimeError:超出最大递归深度”的主要内容,如果未能解决你的问题,请参考以下文章

在 python 中安装模块 - pip、distribute、nose、virtualenv

pip install libvirt-python在virtualenv中失败

没有名为 pip 的模块使用基于 virtualenv 的 python

virtualenv(python3.4), pip install mysqlclient 错误

无法在 Virtualenv 中 pip 安装 MySQL-python

使用 virtualenv/venv 和 pip 管理虚拟环境