3

I'm using python 3.6. Pip is installed along with python. Seems like pip isn't showing up. Tried various solutions available here nothing worked. Please help me solve this.

Verifications done: Path is set as C:\Program Files\Python36\Scripts Added host entries for all 3

PIP error:

C:\Users\>pip
Traceback (most recent call last):
  File "c:\program files\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python36\Scripts\pip.exe\__main__.py", line 5, in <module>
ImportError: cannot import name 'main'

Tried solutions:

pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org {package name}

C:\Users\>pip
Traceback (most recent call last):
  File "c:\program files\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python36\Scripts\pip.exe\__main__.py", line 5, in <module>
ImportError: cannot import name 'main'

C:\Users>python3 -m pip uninstall pip setuptools
'python3' is not recognized as an internal or external command,
operable program or batch file.

C:\Users>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> python3 -m pip uninstall pip setuptools
  File "<stdin>", line 1
    python3 -m pip uninstall pip setuptools
                 ^
SyntaxError: invalid syntax
>>> python3 -m pip uninstall pip setuptools
  File "<stdin>", line 1
    python3 -m pip uninstall pip setuptools
                 ^
SyntaxError: invalid syntax
>>> pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org {package name}
  File "<stdin>", line 1
    pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org {package name}
              ^
SyntaxError: invalid syntax
>>>

Using below version

C:\Users\>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Haran Rajkumar
  • 2,155
  • 16
  • 24
Phoenix2529
  • 127
  • 3
  • 10

5 Answers5

0

Try using

pip2

For python 2. And

pip3

For python 3

And do it from an admin cmd line.

Holger Bille
  • 2,421
  • 1
  • 16
  • 20
  • C:\Users\>pip3 install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org {package name} Traceback (most recent call last): File "c:\program files\python36\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\program files\python36\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Program Files\Python36\Scripts\pip3.exe\__main__.py", line 5, in ImportError: cannot import name 'main' – Phoenix2529 Jun 04 '18 at 07:45
0

Check you have added paths to the these directories (if you are using python3.x versions) - C:\Users\tojose\AppData\Local\Programs\Python\Python3.x and for pip C:\Users\tojose\AppData\Local\Programs\Python\Python3.x\Scripts as pip*.exe's are stored here.

Tom J
  • 1
  • 1
  • 2
  • C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Windows\NSSAppLogs\FW-JetBrains-PyCharm Community Edition-2017.3-3264-171.4694.38;C:\Program Files\Python36;C:\Program Files\Python36\Scripts; – Phoenix2529 Jun 04 '18 at 07:44
  • This is the path added in env var – Phoenix2529 Jun 04 '18 at 07:44
  • Python by default get s installed in local user folder not under program files. Change your path like this - %USERPROFILE%\AppData\Local\Programs\Python\Python36 and %USERPROFILE%\AppData\Local\Programs\Python\Python36\Scripts – Tom J Jun 05 '18 at 09:21
0

Try to use the full path for both pip and the package you want to install.

Example (for Python 3.6):

C:\Python36\Scripts\pip install C:\Python36\requests-2.18.4-py2.py3-none-any.whl

sdgd
  • 723
  • 1
  • 17
  • 38
0

On Windows 10, I had the same problem. PIP 19 was already installed in my system but wasn't showing up. The error was No Module Found.

python -m pip uninstall pip
python -m pip install pip==9.0.3

Downgrading pip to 9.0.3 worked fine for me.

I already answered it HERE

Debu Shinobi
  • 2,057
  • 18
  • 21
0

I had the same issue and have tried several commands without a result. I just simply upgraded my pip version from 19.10 to version 20.3.3 and now it's working fine.

python -m pip install --upgrade pip 

(for windows)

enter image description here

Note: you are applying the pip command inside the Python REPL, which is wrong. By using exit() function come out from Python and write like this.

enter image description here

In my case I have already installed a new version.

bouteillebleu
  • 2,456
  • 23
  • 32