When I update certain packages in my Python installation using pip
I get
TypeError: resolve() got an unexpected keyword argument 'replace_conflicting'
I get this error for certain packages and not others, and have asked about ways to work around it (ideally while continuing to use pip
) in the specific cases where I encounter it; but the question here is what the error means in the first place and what might be the likely cause.
What does this error mean and what could be causing it?
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'
This is caused by having two different versions of setuptools: one in
/System/Library/Frameworks/Python.framework/Versions/2.7
and another in/Library/Python/2.7/site-packages
. Somehow,setuptools.dist.Distribution.fetch_build_eggs
in the newer version callspkg_resources.working_set.resolve
from the older version. The old version of resolve doesn't support the replace_conflicting argument.On my OS X Lion machine, I was able to fix the problem like this:
That is, I used the old version of easy_install to upgrade easy_install and then used that to upgrade pip.
This fixed the problem on my system because it modified
sys.path
so that the new version ofpkg_resources
under/Library/Python
loaded before the old version which can still be found under/System/Library/Frameworks
. An alternative workaround might be to modifysys.path
temporarily using thePYTHONPATH
environment variable, see the Python manual.