-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_NamespacePath object has no attribute sort #4216
Comments
I noticed there was a bug in my setup.py script. The package name had a latent 'skeleton' for the name instead of the proper project name. After correcting that, the issue went away, likely because the proper project name |
Perhaps this issue is only triggered if the package being installed is a non-namespace package but it depends on namespace packages. |
I got the same error (
Three packages are in play (although the first probably isn't important). I have anonymised the package names.
I installed Some extra points:
|
This behavior almost certainly implicates the changes in Setuptools v31 for pypa/setuptools#250. In particular, pypa/setuptools@7e25fd9 updated the way that But it was only in Setuptools 31.0.1 where the What's interesting and I don't yet understand is why deleting the namespace package declaration from acme (for baz) stops the error. I'm unsure what's happening there, but it's probably worthy of some more investigation. |
Python Version Python 3.6.0b2
I am also getting this error. I tried to downgrading to setuptools v28 but it didn't solved. Also this error doesn't pops up in Python 3.5.2. But now I noticed that pip doesn't have this error in Heroku. I have an Django app running on Python 3.6 inside Heroku and it never has any troubles |
For me the solution was to abandon namespace packages; |
This issue is implicated in these failing tests. Although I had surmised above that the issue might be isolated to non-namespace-packages requiring namespace packages, this example is of a namespace package ( |
The issue with those failing tests was corrected by updating the other project to declare its namespace package again. |
@jaraco I met the same question, and I don't know how to fix it ? And my
>> pip3
Traceback (most recent call last):
File "/usr/bin/pip3", line 7, in <module>
from pip import main
File "/usr/local/python3.5.2/lib/python3.5/site-packages/pip/__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/usr/local/python3.5.2/lib/python3.5/site-packages/pip/utils/__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
File "/usr/local/python3.5.2/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3018, in <module>
@_call_aside
File "/usr/local/python3.5.2/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3004, in _call_aside
f(*args, **kwargs)
File "/usr/local/python3.5.2/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3046, in _initialize_master_t
dist.activate(replace=False)
File "/usr/local/python3.5.2/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2578, in activate
declare_namespace(pkg)
File "/usr/local/python3.5.2/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2152, in declare_namespace
_handle_ns(packageName, path_item)
File "/usr/local/python3.5.2/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2092, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/usr/local/python3.5.2/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' |
Same here, my pip appears broken with the same error. I'm using a user install of pip: Traceback (most recent call last):
File "/home/stavros/.local/bin/pip", line 7, in <module>
from pip import main
File "/home/stavros/.local/lib/python3.5/site-packages/pip/__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/home/stavros/.local/lib/python3.5/site-packages/pip/utils/__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
File "/home/stavros/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3018, in <module>
@_call_aside
File "/home/stavros/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3004, in _call_aside
f(*args, **kwargs)
File "/home/stavros/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3046, in _initialize_master_working_set
dist.activate(replace=False)
File "/home/stavros/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2578, in activate
declare_namespace(pkg)
File "/home/stavros/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2152, in declare_namespace
_handle_ns(packageName, path_item)
File "/home/stavros/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2092, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/home/stavros/.local/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' |
I've noticed that this issue will become more prevelant as more packages (wheels especially) are released using later setuptools versions. I've done more analysis in the upstream issue, but I don't have a fix except to update pkg_resources in pip. |
Getting the same error on the following specs:
Python code used to upgrade packages:
|
My pip works again after installing |
I'm finding this issue is becoming more prevalent and is becoming reliably replicable when running Edit: the issue that led me to post this turned out again to be remedied by correcting a flaw in the package being tested. |
I have exactly the same issue, but no need to try complicated things, even asking the version of pip3 fails: $ python3 /usr/local/bin/pip3 --version
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 7, in <module>
from pip import main
File "/usr/local/lib/python3.5/dist-packages/pip/__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/usr/local/lib/python3.5/dist-packages/pip/utils/__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3018, in <module>
@_call_aside
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3004, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3046, in _initialize_master_working_set
dist.activate(replace=False)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2578, in activate
declare_namespace(pkg)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2152, in declare_namespace
_handle_ns(packageName, path_item)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2092, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/usr/local/lib/python3.5/dist-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' I tried to reinstall with An even weirder behavior is that if I execute the $ ipython3 /usr/local/bin/pip3 -- --version
pip 9.0.1 from /usr/local/lib/python3.5/dist-packages (python 3.5) |
@jaraco Would vendoring a setuptools >= 31.0.1 fix this issue? |
@pradyunsg in my case, vendoring setuptools 34.3.0 fixed it for me. |
Yes. See eaccb88. |
@jaraco Is this in master? I don't see the relevant change entry. |
Is there a pip version that we know is before this problem arose? It would be useful to be able to advise users "downgrade to pip X.Y.Z until this issue is marked as fixed" |
see #4330
alternatively, try
|
I tried these tricks, and as far as now nothing worked, so here is my durty-and-useful fix: orig_path.sort(key=position_in_sys_path) with try:
orig_path.sort(key=position_in_sys_path)
except AttributeError:
print("BUG: Is it bad if orig_path is not sorted correctly?") |
Can there be a pip 9.0.2 with this fix only - a newer version of setuptools vendored? One way to do it would be to branch off 9.0.1, cherry pick the fix mentioned by @jaraco and tag it 9.0.2, release and merge back into master. |
@Naereen silencing the error may cause issues if a different bug arises, better print |
@LoganDark of course, my "fix" was not meant to be merged or used, barely just to have a functional |
I believe pip has a documented process for devendoring a dependency. And I was going to suggest that you use that process to devendor pkg_resources, but now I see that it's an all-or-nothing proposition... so you can't simply supply devendor setuptools. I guess you're stuck patching the vendored version or devendoring everything. |
On Wed, 29 Nov 2017, 03:06 Jason R. Coombs, ***@***.***> wrote:
I believe pip has a documented process for devendoring a dependency
<https://github.com/pypa/pip/blob/master/src/pip/_vendor/README.rst#debundling>.
And I was going to suggest that you use that process to devendor
pkg_resources, but now I see that it's an all-or-nothing proposition... so
you can't simply supply devendor setuptools. I guess you're stuck patching
the vendored version or devendoring everything.
Indeed, it is an all-or-nothing approach.
IIRC, it is semi supported in the sense that there's no guarantee that
devendoring would just work out of the box -- it will, for a lot of cases,
but there's definitely edge cases which result in some extremely weird
behaviour. This makes me think that debundling is meant more for someone
like a downstream distributor (like Debian) who can put in the effort of
validating the setup.
Debundled pip is no longer tested on pip's CI. I don't have the PR number
or a link to discussions handy. The documentation needs to be updated.
—
… You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4216 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADH7SV1msCI_g7fy9QW_kfGo_r4K5fRSks5s7HzCgaJpZM4Lb1jc>
.
|
Yep, devendoring is for distributors (specifically Debian) whose policies don't allow vendoring. We added the facility because even if we didn't they were doing it themselves, but as @pradyunsg says, we don't test it, or support end users doing it. (As far as I know - it's not something I've worked on directly myself, either). |
Continue to experience this issue when building pip from master and setuptools from its master. Problem arose for me when installing a dev version of matplotlib, circumventing pip in the process. |
Interesting... @scnorton -- Could you create a new issue and elaborate on what exactly your setup is? |
If I encounter the issue again, I will. Reinstalling python entirely has resolved the issue for now. |
I'm quote surprised to see that this issue is still open, especially after 10 months when I proposed a (durty) 3-line fix (#4216 (comment))... |
I deleted |
I have de same issue, this occurred when i try to install mpl_toolkits basemap. then call pip3 was imposible, the solution was: pip work's again |
@Naereen The file path specified in your comment doesn't exist on my system Ubuntu 16.04. |
I removed ~/.local/lib/python3.5/site-packages/matplotlib-2.2.2-py3.5-nspkg.pth file and it solved the issue for me! |
Changing #orig_path.sort(key=position_in_sys_path)
orig_path = sorted(orig_path, key=position_in_sys_path) |
Confirming @korolevivan's finding - removing matplotlib did the trick:
|
I run in the same error on ubuntu 16.04 with setuptools-39.0.1 pip-9.0.3. Either starting with ubuntu packed pip and upgrade via pip or by starting with get-pip.py ends up in the error. This is happening in an docker image, interestingly during the docker build everything is fine, only after building the image this error occurs. editing the line mentioned above "solves" the problem. |
Re-installing python worked for me :) |
worked for me: Ubuntu 16.04.4 LTS |
升级pip就好了。$ sudo pip install --upgrade pip |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
It seems that pip by way of vendoring Setuptools is triggering the issue reported in pypa/setuptools#885 (and may likely be implicated in the ongoing reports of users experiencing the issue). Here's a traceback that occurs when
pip freeze
is invoked bytox
during a test run after completing thedevelop-inst-no-deps
step.I imagine the only fix is to re-vendor setuptools with 31.0.1 or later.
The text was updated successfully, but these errors were encountered: