【问题标题】:What does the error "resolve() got an unexpected keyword argument 'replace_conflicting'" mean?错误“resolve() got an unexpected keyword argument 'replace_conflicting'”是什么意思?
【发布时间】:2014-05-02 06:53:42
【问题描述】:

当我使用 pip 更新我的 Python 安装中的某些包时,我得到了

TypeError: resolve() got an unexpected keyword argument 'replace_conflicting'

对于某些包而不是其他包,我得到了这个错误,have asked 关于在我遇到它的特定情况下解决它的方法(最好是继续使用pip);但这里的问题是错误首先意味着什么以及可能的原因是什么。

这个错误是什么意思,是什么原因造成的?


Downloading/unpacking xattr
  Downloading xattr-0.7.5.tar.gz
  Running setup.py (path:/private/tmp/pip_build_root/xattr/setup.py) egg_info for package xattr
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/private/tmp/pip_build_root/xattr/setup.py", line 67, in <module>
        cmdclass={'build': cffi_build},
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 112, in setup
        _setup_distribution = dist = klass(attrs)
      File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 239, in __init__
        self.fetch_build_eggs(attrs.pop('setup_requires'))
      File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 264, in fetch_build_eggs
        replace_conflicting=True
    TypeError: resolve() got an unexpected keyword argument 'replace_conflicting'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/private/tmp/pip_build_root/xattr/setup.py", line 67, in <module>

    cmdclass={'build': cffi_build},

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 112, in setup

    _setup_distribution = dist = klass(attrs)

  File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 239, in __init__

    self.fetch_build_eggs(attrs.pop('setup_requires'))

  File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 264, in fetch_build_eggs

    replace_conflicting=True

TypeError: resolve() got an unexpected keyword argument 'replace_conflicting'

【问题讨论】:

    标签: python installation package pip conflict


    【解决方案1】:

    这是由两个不同版本的 setuptools 引起的:一个在 /System/Library/Frameworks/Python.framework/Versions/2.7 中,另一个在 /Library/Python/2.7/site-packages 中。不知何故,新版本中的setuptools.dist.Distribution.fetch_build_eggs 调用了旧版本中的pkg_resources.working_set.resolve。旧版本的 resolve 不支持 replace_conflicting 参数。

    在我的 OS X Lion 机器上,我能够像这样解决问题:

    $ sudo python /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/easy_install.py -U setuptools
    $ sudo easy_install -U pip
    

    也就是我用老版本的easy_install升级easy_install,然后用那个升级pip。

    这解决了我系统上的问题,因为它修改了sys.path,使得/Library/Python 下的pkg_resources 的新版本在/System/Library/Frameworks 下仍然可以找到的旧版本之前加载。另一种解决方法可能是使用PYTHONPATH 环境变量临时修改sys.path,请参阅the Python manual。

    【讨论】:

    • 这似乎是setuptools 中的一个错误。没有办法访问当前版本应该调用不同位置的旧版本。
    • 也许吧。在运行上述命令之前,import pkg_resources 之后,pkg_resources.__file__ 是/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.pyc。运行命令后,它是/Library/Python/2.7/site-packages/setuptools-3.4.4-py2.7.egg/pkg_resources.pyc。我认为这与 Mac 上的 sys.path 设置有关。
    • 嗯。也许您的问题与我的不同,或者我们的 pip/easy_install 配置有所不同。您是否有两份 pkg_resources.pyc,一份在 /System/Library/Frameworks 下,一份在 /Library/Python 下? pkg_resources.__file__ 的值是多少?
    • 运行上述命令后,我的 sys.path 开始如下: ['', '/Library/Python/2.7/site-packages/setuptools-3.4.4-py2.7.egg ', ... 也就是说,setuptools egg 位于标准位置之前。我认为这才是真正解决问题的原因。我不会称其为理想的解决方案,但这就是我所拥有的。看起来您的 easy_install 没有将 setuptools 安装为鸡蛋,但我的安装了。 OS X 在 sys.path 中优先考虑鸡蛋,这就是为什么这为我解决了版本不匹配问题。
    • 试试PYTHONPATH=/Library/Python/2.7/site-packages pip ...,它应该将新设置工具的位置放在该运行的 sys.path 开头或附近。
    猜你喜欢
    • 2014-03-07
    • 1970-01-01
    • 1970-01-01
    • 2021-01-19
    • 1970-01-01
    • 2022-12-02
    • 2022-01-12
    • 2015-09-23
    • 2021-06-03
    相关资源
    最近更新 更多