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

ModuleNotFoundError: No module named 'pip' #5710

Closed
GarbageYard opened this issue Aug 17, 2018 · 10 comments
Closed

ModuleNotFoundError: No module named 'pip' #5710

GarbageYard opened this issue Aug 17, 2018 · 10 comments
Labels
auto-locked Outdated issues that have been locked by automation type: support User Support

Comments

@GarbageYard
Copy link

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)
@benoit-pierre
Copy link
Member

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.

@pradyunsg pradyunsg added the type: support User Support label Aug 17, 2018
@pradyunsg
Copy link
Member

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).

@GarbageYard
Copy link
Author

@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

@benoit-pierre
Copy link
Member

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

@GarbageYard
Copy link
Author

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?

@benoit-pierre
Copy link
Member

Manually download it from your browser?

@GarbageYard
Copy link
Author

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

@bukreevai
Copy link

@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

@aonamrata
Copy link

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.

@lock
Copy link

lock bot commented May 30, 2019

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.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 30, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation type: support User Support
Projects
None yet
Development

No branches or pull requests

5 participants