Skip to content
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' #45

Closed
jdknight opened this issue Sep 16, 2017 · 7 comments
Closed

'_NamespacePath' object has no attribute 'sort' #45

jdknight opened this issue Sep 16, 2017 · 7 comments
Milestone

Comments

@jdknight
Copy link
Member

The automated build does not work. The py35 build fails with the following (ex. job 267816857):

Traceback (most recent call last):
  File "/home/travis/build/tonybaloney/sphinxcontrib-confluencebuilder/.tox/py35/bin/pip", line 7, in <module>
    from pip import main
  File "/home/travis/build/tonybaloney/sphinxcontrib-confluencebuilder/.tox/py35/lib/python3.5/site-packages/pip/__init__.py", line 26, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "/home/travis/build/tonybaloney/sphinxcontrib-confluencebuilder/.tox/py35/lib/python3.5/site-packages/pip/utils/__init__.py", line 27, in <module>
    from pip._vendor import pkg_resources
  File "/home/travis/build/tonybaloney/sphinxcontrib-confluencebuilder/.tox/py35/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3018, in <module>
    @_call_aside
  File "/home/travis/build/tonybaloney/sphinxcontrib-confluencebuilder/.tox/py35/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3004, in _call_aside
    f(*args, **kwargs)
  File "/home/travis/build/tonybaloney/sphinxcontrib-confluencebuilder/.tox/py35/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3046, in _initialize_master_working_set
    dist.activate(replace=False)
  File "/home/travis/build/tonybaloney/sphinxcontrib-confluencebuilder/.tox/py35/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2578, in activate
    declare_namespace(pkg)
  File "/home/travis/build/tonybaloney/sphinxcontrib-confluencebuilder/.tox/py35/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2152, in declare_namespace
    _handle_ns(packageName, path_item)
  File "/home/travis/build/tonybaloney/sphinxcontrib-confluencebuilder/.tox/py35/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2092, in _handle_ns
    _rebuild_mod_path(path, packageName, module)
  File "/home/travis/build/tonybaloney/sphinxcontrib-confluencebuilder/.tox/py35/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 suspect that this problem is not really with the current source of this extension, but rather an issue with pip and/or the tox configuration being used. Using a more recent version pip and setuptools shows that the tox build works; however, I can't seem to get it to work with Travis CI (I haven't had that much experience with using it).

I believe the following bug covers of the reason why, but I'm not 100% sure how to apply the workaround changes for the current automated build process:

pypa/pip - '_NamespacePath' object has no attribute 'sort'
pypa/pip#4216

I was hoping a pip v9.0.2 update would fix this, but I'm not sure when an update will ever be released.

@jdknight jdknight added this to the 0.7 milestone Sep 16, 2017
jdknight added a commit that referenced this issue Sep 29, 2017
The Travis CI environment prepares a test environment with the most
recent version of pip available (v9.0.1); however, using this
version results in the following error [1]:

    AttributeError: '_NamespacePath' object has no attribute 'sort'

Adjusting the tox requirements to forcefully update pip to the
newest version for the interim. When pip v9.0.2+ is available, this
commit can be reverted.

[1]: #45

Signed-off-by: James Knight <james.d.knight@live.com>
@jdknight
Copy link
Member Author

jdknight commented Oct 3, 2017

This issue has been addressed on master to allow Travis CI to be functional again.

For user's experiencing the same issue in their environment, it is recommended to update their setuptools package (python -m pip install --upgrade setuptools).

@jdknight jdknight closed this as completed Oct 3, 2017
@YB-Park
Copy link

YB-Park commented Nov 6, 2017

/home/travis/build/tonybaloney/sphinxcontrib-confluencebuilder/.tox/py35/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py

fix line 2121 as below.
orig_path.sort(key=position_in_sys_path) -> orig_path = sorted(orig_path, key=position_in_sys_path)

@WenkaiChen
Copy link

@YB-Park Thanks a lot, your solution really works for me!

jdknight added a commit that referenced this issue Jan 20, 2018
The most recent version of Travis CI's Python build [1] appears to no
longer require a force update of the pip command line [2]. Tested with
image 'travisci/ci-garnet:packer-1512502276-986baf0'.

[1]: https://docs.travis-ci.com/user/common-build-problems/#Troubleshooting-Locally-in-a-Docker-Image
[2]: #45

Signed-off-by: James Knight <james.d.knight@live.com>
@FaJoBenWhales
Copy link

YB-Park
the same thing workd for me too
Thanks a lot, you made my day
Jochen

jdknight added a commit that referenced this issue Jan 25, 2018
Removes the custom Python path explicitly set in the tox configuration
file. This should resolve situations [1] where pip may not install
required packages (and dependencies) into target virtualenv since they
are already provided in PYTHONPATH (see also [2]).

[1]: #45
[2]: tox-dev/tox#330

Signed-off-by: James Knight <james.d.knight@live.com>
jdknight added a commit that referenced this issue Jan 25, 2018
With an environment correction [1], there is no need to forcefully
upgrade pip to the most recent development snapshot [2]. Tested with
image 'travisci/ci-garnet:packer-1512502276-986baf0' [3].

[1]: e88ef73
[2]: #45
[3]: https://docs.travis-ci.com/user/common-build-problems/#Troubleshooting-Locally-in-a-Docker-Image

Signed-off-by: James Knight <james.d.knight@live.com>
@cestas
Copy link

cestas commented Feb 28, 2018

Thank you YB_Park, that helped me so much. I have no idea though why that issue came up today, even though yesterday it worked just fine!

@drsxr
Copy link

drsxr commented Mar 18, 2018

Thanks YB_Park. That line fix really should be incorportated into the next master build.

suggest line 2121 be changed to:

try:
orig_path=sorted(orig_path,key=position_in_sys_path)
except AttributeError:
print("BUG: Is it bad if orig_path is not sorted correctly?")

@trantuanvu1602
Copy link

Thanks YB_Park. You made my day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants