google-cloud-python: AttributeError: '_NamespacePath' object has no attribute 'sort'
- Ubuntu 16.04.1 LTS
- Python 3.5.2 :: Anaconda 4.2.0 (64-bit)
I was trying install with pip install --upgrade google-cloud but I get the following AttributeError: ‘_NamespacePath’ object has no attribute ‘sort’
Below is the stack trace:
Traceback (most recent call last):
File "/home/ubuntu/anaconda3/bin/pip", line 7, in <module>
from pip import main
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/pip/__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/pip/utils/__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3018, in <module>
@_call_aside
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3004, in _call_aside
f(*args, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3046, in _initialize_master_working_set
dist.activate(replace=False)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2578, in activate
declare_namespace(pkg)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2152, in declare_namespace
_handle_ns(packageName, path_item)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2092, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2121, in _rebuild_mod_path
orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 53 (14 by maintainers)
Links to this issue
Commits related to this issue
- It's possible that an update of setuptools is also needed. Per https://github.com/googleapis/google-cloud-python/issues/2990#issuecomment-283586901 — committed to arokem/pyAFQ by arokem 5 years ago
- It's possible that an update of setuptools is also needed. Per https://github.com/googleapis/google-cloud-python/issues/2990#issuecomment-283586901 — committed to arokem/pyAFQ by arokem 5 years ago
- It's possible that an update of setuptools is also needed. Per https://github.com/googleapis/google-cloud-python/issues/2990#issuecomment-283586901 — committed to arokem/pyAFQ by arokem 5 years ago
- admin/build-doc: upgrade pip setuptools first on certain distros, buggy pip and setuptools are used, so we need to upgrade them first. see also: googleapis/google-cloud-python#2990 and pypa/setuptoo... — committed to tchaikov/ceph by tchaikov 4 years ago
- admin/build-doc: upgrade pip setuptools first on certain distros, buggy pip and setuptools are used, so we need to upgrade them first. see also: googleapis/google-cloud-python#2990 and pypa/setuptoo... — committed to jmolmo/ceph by tchaikov 4 years ago
Is there a workaround for this? I can’t install
google-cloudEdit:
pip install --upgrade pipandpip install --upgrade setuptoolsdid the trick. Maybe this can be closedWorkaround / Fix
With
setuptools==34.3.0the problem is no longer there.Neither upgrading
pipnor upgradingsetuptoolshelped 😦.@MarSoft bit tricky in a chicken-egg kind of way:
Notably, you just need to update your pip & setuptools.
On Wed, Feb 8, 2017, 8:55 PM Danny Hermes notifications@github.com wrote:
I fixed the problem by commenting (or removing) the line:
orig_path.sort(key=position_in_sys_path)[I think is line number 2066] both in “/usr/lib/python3/dist-packages/pkg_resources/__init__.py” and “~/.local/lib/python3.5/site-packages/pip/_vendor/__init.py__”.This problem has begun when I updated pip using “
sudo pip --upgrade python-pip”. I’m on Ubuntu 16.04 LTS.I had the same problem using poetry.
Running
instead of
fixed the issue.
For all those coming by, I have done a “deep” dive today to understand this issue and found out that
pip==9.0.1(current latest) still comes with a broken version ofsetuptools.This
'_NamespacePath' object has no attribute 'sort'error is unavoidable if you usepython setup.py installon one of our packages (they are all namespace packages).If you have a fresh environment and only use
pip installto install our packages, you will not have this issue.Sorry for the inconvenience.
References:
Updating pip and the setup tools did the work for me.
python -m pip install --upgrade pippython -m pip install --upgrade setuptoolsUPDATE, mines working with pip from bleeding edge, no steuptools upgrade (thanks @bkleef ):
easy_install pipfollowed bypip install --upgrade pip && pip install --upgrade setuptoolsworked for meI found a workaround:
$ pip uninstall setuptools$ pip install setuptools==39.1.0I ran into this issue today when upgrading pip from 9.0.1 to 9.0.2 . I don’t believe it is a setuptools issue as I upgraded to 39.0.0 . Eventually nothing would install. I went into pip and bypassed line 2121? (the keysorter line) and it works, although I have no idea if this will be stable.
Disappointing that this would be an issue 2 years out for a package as important as pip.
@dhermes I ended up here after going round the houses, though even with a “fresh” environment, and using
pipfor all package installtion there is still a problem, see:The only way I have been able to get around it is to comment out the offending line in
/path/to/my/venv/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.pyIm still reading through to see what effect this will have, though im not going to be able to do that on my PAAS (flexible environment in appengine)
@Rockyyost This error is 100% in
pip. It seems you have a broken version ofpip.$ pip install --upgrade setuptools==41.2.0You dont need to downgrade setuptools to 39.1.0 from 41.0.1. It works perfectly after upgrading to 41.2.0. @oldmonkABA @yselivonchykFor what it’s worth I was having this issue with
googleapis-common-protosonUbuntu 16.04with the latestsetuptoolsandpipusingpython3.6, but not on my Mac.I was using a virtualenv and discovered that my Mac had
virtualenv 15.1.0and the Ubuntu hadvirtualenv 15.0.1and that upgrading thevirtualenvallowed the install to work.@dhermes indeed but 9.0.2 is not yet on pypa and so you need to upgrade like:
don’t try to giving up
For me setuptools-41.0.1 was giving the error. Downgrading it to 39.1.0 as mentioned solved the issue for python 3.6.7
Currently experiencing this issue with the following setup
python 3.5.2 pip 18.0 virtualenv 15.0.1 setuptools 40.2.0
When installing google-cloud-bigquery setuptools fails to install googleapis-common-protos with the following error:
Seems the problem has been re-introduced with a newer version of setuptools which is confusing for anyone who finds this thread.
Temporary Fix: Downgrading setuptools to version 34.3.0 is mentioned by @MarSoft seems to fix this issue.
I also still have the problem, with the newest pip version.
Now also running in this error with easy_install
ImportError: No module named py31compat
we are facing the same issue on latest anaconda (and python 3.6.1) - we did the same thing as @bkleef and got it working (pip install)