question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

_NamespacePath object has no attribute sort (31.0.0)

See original GitHub issue

When pip installing a package that shares a namespace it fails out on 31.0.0 but installs fine on 28.8.0

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.5/site-packages/setuptools/__init__.py", line 10, in <module>
        from setuptools.extern.six.moves import filter, filterfalse, map
      File "/usr/lib/python3.5/site-packages/setuptools/extern/__init__.py", line 1, in <module>
        from pkg_resources.extern import VendorImporter
      File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3015, in <module>
        @_call_aside
      File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2999, in _call_aside
        f(*args, **kwargs)
      File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3043, in _initialize_master_working_set
        for dist in working_set
      File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3043, in <genexpr>
        for dist in working_set
      File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2573, in activate
        declare_namespace(pkg)
      File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2147, in declare_namespace
        _handle_ns(packageName, path_item)
      File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2087, in _handle_ns
        _rebuild_mod_path(path, packageName, module)
      File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2116, in _rebuild_mod_path
        orig_path.sort(key=position_in_sys_path)
    AttributeError: '_NamespacePath' object has no attribute 'sort'

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:23
  • Comments:73 (37 by maintainers)

github_iconTop GitHub Comments

42reactions
SeungKil-Paekcommented, Jun 12, 2017

I modified the function _rebuild_mod_path of the file(.../site-packages/pip/_vendor/pkg_resources/__init__.py), which worked:

orig_path_t = list(orig_path) # added
#orig_path.sort(key=position_in_sys_path) # commented
orig_path_t.sort(key=position_in_sys_path) # added
#module.__path__[:] = [_normalize_cached(p) for p in orig_path] # commented
module.__path__[:] = [_normalize_cached(p) for p in orig_path_t] # added

24reactions
chexexcommented, Sep 20, 2017

hmm… how might one follow @frankyaorenjie 's solution just above if attempting to use pip to upgrade (or uninstall) setuptools also throws that error?

This helped me with the issue

easy_install pip
easy_install setuptools
Read more comments on GitHub >

github_iconTop Results From Across the Web

pip3 error - '_NamespacePath' object has no attribute 'sort'
I have tried running pip3 install --upgrade pip setuptools according to some answers, but every pip command gives me the error. I'm stuck...
Read more >
_NamespacePath' object has no attribute 'sort' still not work ...
Python 3.6.5 pip 19.0.2 setuptools 40.8.0 virtualenv 16.0.0 Have ... _NamespacePath' object has no attribute 'sort' still not work #7386.
Read more >
attributeError: '_NamespacePath' object has no attribute 'sort'
hello I work on Python 3.6 and I could not install a module : pip3.6 ... attributeError: '_NamespacePath' object has no attribute 'sort'....
Read more >
python 2.7 - Pip does not work after upgrade to ubuntu-16.10 - Stack ...
I read that the error is due to setuptools version 31.0.0 and it should be lower than ... AttributeError: '_NamespacePath' object has no...
Read more >
解决pip 问题AttributeError: '_NamespacePath' object has no ...
AttributeError : '_NamespacePath' object has no attribute 'sort' ... 简单来说就是:在__init__.py中第2021行orig_path.sort时没有sort属性,参考 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found