5

Pip is broken in my anaconda environment. Pip3 is missing and normal pip is broken.

Traceback (most recent call last):
 File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\Scripts\pip-script.py", line 3, in <module>
import pip
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\utils\__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3018, in <module>
@_call_aside
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3004, in _call_aside
f(*args, **kwargs)
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3046, in _initialize_master_working_set
dist.activate(replace=False)
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2578, in activate
declare_namespace(pkg)
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2152, in declare_namespace
_handle_ns(packageName, path_item)
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2092, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\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'`

This is the error. Even if I uninstall pip and reinstall it, it still wont work. I thought maybe I could write all packages of the environment in a .yml file and create a new environment which automatically installs all the packages from the .yml. Cloning the environment didnt work. I cant use anything with pip so I cant upgrade pip or anything else. Reinstalling the setuptools didnt work. Any idea how I can fix this? Thank you very much for your help.

EDIT: With Johns help I could solve the problem. I cant accept my own answer in 2 days so I have to keep it open because maybe someone else encounters the same problem.

Ilovescience
  • 103
  • 2
  • 8
  • it looks like you're using the Anaconda distribution of python. Have you tried 'conda install pip' ? – Natsfan Aug 29 '17 at 18:18
  • Another option is that you are running the wrong pip. Type 'which pip' and see if this is the correct pip. – Natsfan Aug 29 '17 at 18:20
  • I have tried conda install pip - it didnt work. But thank you very much for your answer and time – Ilovescience Aug 29 '17 at 18:54
  • I cant use which pip. I am on a windows machine dont know maybe this is a linux/osx only command. Neither as a cmd command nor as a python command which pip wont work. Any idea what I could do? – Ilovescience Aug 29 '17 at 19:00
  • Sorry. I thought you were on a unix/linux box. If you directory path is not set correctly you may keep using broken pip even after reinstalling. But I'm window illiterate so I have no idea what to do. Are you using a command line on windows? – Natsfan Aug 29 '17 at 19:09
  • Yes I am using command line on windows. You are probably right that my path is incorrect and that this is why even after reinstallation it is still broken. Thank you for your help. – Ilovescience Aug 29 '17 at 19:14
  • I hope I helped... lol – Natsfan Aug 29 '17 at 19:17
  • I tried this: https://stackoverflow.com/questions/23708898/pip-is-not-recognized-as-an-internal-or-external-command but it still isnt working. Any idea what else it could be other than the wrong path or isnt this the right way to change the path? – Ilovescience Aug 29 '17 at 20:44
  • i'm out of options but someone should come along soon to answer your question. I don't know how to set your path on a windows box. you might ask that question on this list! You can have more than one question open. But it may be considered a duplicate. – Natsfan Aug 29 '17 at 20:53
  • Thank you very much for your great help, effort and time. I managed to fix the problem by deleting the pip.exe and pipscript,py from the anaconda installation and setting the pip environment variable to the pip from another python installation. Again appreciate your quick answers and suggestions much thanks. – Ilovescience Aug 29 '17 at 21:06

2 Answers2

4

Try this:

conda install pip

Normal way of reinstalling pip will not fix issues in anaconda environment.

mx0
  • 4,605
  • 10
  • 39
  • 47
Mike Z
  • 41
  • 3
0

I managed to fix the problem by deleting the pip.exe and pipscript,py from the anaconda installation and setting the pip environment variable to the pip from another python installation.

Ilovescience
  • 103
  • 2
  • 8