Pip: ModuleNotFoundError: No module named 'pip'

Created on 17 Aug 2018  路  10Comments  路  Source: pypa/pip

Environment

  • pip version: 9.0.3
  • Python version: 3.6
  • OS: Windows Server 2016 Datacenter

Description
My system admin installed Python 3.6 for me in my AWS workspace and i requested him to update the pip version to 18 but while he was trying to upgrade the version, he ran into error. All below-mentioned commands were executed from a Powershell window in Administrative mode:

Output

PS D:\python\3.6\scripts> pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940
/pip-18.0-py2.py3-none-any.whl (1.3MB)
    100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 1.3MB 720kB/s
Installing collected packages: pip
  Found existing installation: pip 9.0.3
    Uninstalling pip-9.0.3:
Exception:
Traceback (most recent call last):
  File "d:\python\3.6\lib\shutil.py", line 544, in move
    os.rename(src, real_dst)
OSError: [WinError 17] The system cannot move the file to a different disk drive: 'd:\\python\\3.6\\scripts\\pip.exe' ->
 'C:\\Users\\sdgadmin\\AppData\\Local\\Temp\\pip-o9ithn08-uninstall\\python\\3.6\\scripts\\pip.exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\python\3.6\lib\site-packages\pip\basecommand.py", line 215, in main
  File "d:\python\3.6\lib\site-packages\pip\commands\install.py", line 342, in run
  File "d:\python\3.6\lib\site-packages\pip\req\req_set.py", line 778, in install
  File "d:\python\3.6\lib\site-packages\pip\req\req_install.py", line 754, in uninstall
  File "d:\python\3.6\lib\site-packages\pip\req\req_uninstall.py", line 115, in remove
  File "d:\python\3.6\lib\site-packages\pip\utils\__init__.py", line 267, in renames
  File "d:\python\3.6\lib\shutil.py", line 559, in move
    os.unlink(src)
PermissionError: [WinError 5] Access is denied: 'd:\\python\\3.6\\scripts\\pip.exe'

PS D:\python\3.6\scripts> pip list
Traceback (most recent call last):
  File "d:\python\3.6\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\python\3.6\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Python\3.6\Scripts\pip.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'

PS D:\python\3.6\scripts> pip3 install --upgrade pip
Traceback (most recent call last):
  File "d:\python\3.6\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\python\3.6\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Python\3.6\Scripts\pip3.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'

PS D:\python\3.6\scripts> pip3 install --upgrade pip3
Traceback (most recent call last):
  File "d:\python\3.6\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\python\3.6\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Python\3.6\Scripts\pip3.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'

PS D:\python\3.6\scripts> pip install --upgrade pip
Traceback (most recent call last):
  File "d:\python\3.6\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\python\3.6\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Python\3.6\Scripts\pip.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'

PS D:\python\3.6\scripts> pip.exe install --upgrade pip
Traceback (most recent call last):
  File "d:\python\3.6\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\python\3.6\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Python\3.6\Scripts\pip.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'

Are we doing something wrong here? I also checked few links that suggested using _easy_install_. I tried that as well but ran into issues.

PS D:\python\3.6\scripts> .\easy_install.exe pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
d:\python\3.6\lib\site-packages\setuptools\pep425tags.py:89: RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python
 ABI tag may be incorrect
  warn=(impl == 'cp')):
d:\python\3.6\lib\site-packages\setuptools\pep425tags.py:93: RuntimeWarning: Config variable 'WITH_PYMALLOC' is unset, P
ython ABI tag may be incorrect
  warn=(impl == 'cp')):
Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/p
ip-18.0-py2.py3-none-any.whl#sha256=070e4bf493c7c2c9f6a08dd797dd3c066d64074c38e9e8a0fb4e6541f266d96c
error: Download error for https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3
703d2ddaf940/pip-18.0-py2.py3-none-any.whl#sha256=070e4bf493c7c2c9f6a08dd797dd3c066d64074c38e9e8a0fb4e6541f266d96c: [SSL
: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
auto-locked support

Most helpful comment

Manually download it from your browser?

All 10 comments

easy_install is deprecated, don't use it.

First: use python -m pip when updating pip on windows (otherwise pip's launcher cannot be updated). It also looks like you might be suffering from #5701.

Hey @GarbageYard!

You'd want to use python -m pip install --upgrade pip. That's the only way to upgrade on Windows, since Windows doesn't allow updating an executable as it's being used (which is what happens with pip install --upgrade pip).

@benoit-pierre / @pradyunsg : I tried both suggestions but i am getting the following issue:

PS D:\python\3.6> python -m pip
D:\Python\3.6\python.exe: No module named pip

PS D:\python\3.6> python -m pip install --upgrade pip
D:\Python\3.6\python.exe: No module named pip

Yes, because you current installation is broken, I suggest re-installing from get-pip.py.

I just tried that as well as mentioned here but getting SSL issue.

PS D:\python\3.6\Scripts> curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
curl : The request was aborted: Could not create SSL/TLS secure channel.
At line:1 char:1
+ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Any way i can fix this error?

Manually download it from your browser?

Thanks @benoit-pierre! After reading your last comment, was feeling embarrassed. :P It worked using get-pip.py. Thanks a lot! :+1:

@benoit-pierre ,
I'm install Pip wiht get-pip.py
Installing collected packages: pip, setuptools, wheel Successfully installed pip-18.1 setuptools-40.6.3 wheel-0.32.3
And I have the same error.
OS: Win 10 x64
Python: 3.6.7

I had similar issue where installing chalice was uninstalling pip..

Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\python36\\scripts\\pip3.exe'

So i tried this:
re-install pip using get-pip.py > create virtualenv > pip install chalice==1.6.2
and it worked.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings