pip3 error - '_NamespacePath' object has no attribute 'sort' pip3 error - '_NamespacePath' object has no attribute 'sort' python python

pip3 error - '_NamespacePath' object has no attribute 'sort'


I met the same issue with python 3.5.2 and pip3 (9.0.1). And I fixed it by following this workaround: https://github.com/pypa/setuptools/issues/885#issuecomment-307696027

More specifically, I edited line #2121~2122 of this file: "sudo vim /usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py"

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


Upgrading setuptools worked for me:

pip3 install --upgrade setuptools


This may sound weird, because I had this issue and I had tried everything mentioned in SO and GitHub issues. But then I installed pip with easyinstall and pip command is working. Maybe now there are 2 pip packages now. But error is gone.

easy_install pip