Question
Asked By – Woootiness
I’ve installed the latest python (2.7.9) bundled with pip and setuptools for windows 32-bit. I’ve tried reinstalling pip but the problem persists.
Here’s the error after running pip --version
in Administrator cmd:
Traceback (most recent call last):
File "D:\Python\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "D:\Python\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "D:\Python\Scripts\pip.exe\__main__.py", line 5, in <module>
ImportError: cannot import name main
Now we will see solution for issue: ImportError: cannot import name main when running pip –version command in windows7 32 bit
Answer
Even though the original question seems to be from 2015, this ‘bug’ seems to affect users installing pip-10.0.0
as well.
The workaround is not to modify pip
, however to change the way pip is called. Instead of calling /usr/bin/pip
call pip
via Python itself. For example, instead of the below:
pip install <package>
If from Python version 2 (or default Python binary is called python
) do :
python -m pip install <package>
or if from Python version 3:
python3 -m pip install <package>
This question is answered By – Wan B.
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0