77

After a pip update, pip has stopped working completely.

Z:\>pip install matplotlib
Traceback (most recent call last):
  File "c:\program files\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python37\Scripts\pip.exe\__main__.py", line 9, in <module>
TypeError: 'module' object is not callable

Any help please?

Edit: I am working on windows 10

Agustin
  • 1,458
  • 1
  • 13
  • 30

10 Answers10

92

All credit for this goes to user han_solo, who left the answer as a comment, instead of as an answer:

Instead of pip install stdlib_list --user

use python -m pip install stdlib_list --user

Replace stdlib_list with matplotlib or whatever the name is of the package you want.

Toothpick Anemone
  • 4,290
  • 2
  • 20
  • 42
  • 23
    Why is this happening? – Darkgaze Nov 19 '19 at 19:19
  • 1
    yuck. but at least you can set an alias `alias pip="python -m pip"` (or `alias pip="python3 -m pip"`). add that to ~/.bash_aliases or your shell rc file – fbas Nov 26 '19 at 02:10
  • use `python3 -m pip install stdlib_list --user` for python3. module name is still `pip` for this case. – smcg Jan 09 '20 at 21:19
15

I've had the same issue as you, and I solved it uninstalling pip and installing again.

To uninstall: python -m pip uninstall pip

To install, follow the instructions: https://www.liquidweb.com/kb/install-pip-windows/

After that you will going to have a older but functional 19.0.3 version.

rdemarqui
  • 151
  • 4
6

If you do not wish to use the long command every time python -m pip install <package>, reinstall pip to the older version where this error wasn't there.

python -m pip install pip==19.0.3

Now you will be able to use pip install matplotlib or pip list normally.

And whenever the bug is resolved, upgrade pip like you did before.

mudit
  • 61
  • 1
  • 2
5

This worked for me, uninstall pip 19.3.1 and replace with 19.0.3, error gone.

python -m pip install pip==19.0.3 --user
Camilo Caquimbo
  • 133
  • 1
  • 6
2

Similar to what @han_solo said, but if your running python3, instead of using:

python -m pip install stdlib_list --user

try using:

python3 -m pip install stdlib_list --user

  • 3
    Alden, Rather next time just edit the existing answer and add `python3 -m pip install stdlib_list --user` instead of having a whole new answer just to add a number – PhillipJacobs Nov 07 '19 at 19:20
2

Have the habit of installing any python packages with pip using python -m, say for installing numpy use below command:

python -m pip install numpy

In case if it errros out with the environment permission error append --user in the same command:

python -m pip install numpy --user

Piyush Upadhyay
  • 427
  • 4
  • 12
0

I had the same issue with h5py-2.7.1, and the warnings were gone after upgrading to h5py-2.10.0.

Ashkan
  • 31
  • 4
0

I cannot leave the comments yet, therefore I've decided to leave a link with an explanation why this can happen: https://github.com/pypa/pip/issues/5599

If this is the case you can try to fix it by downgrading the pip version with the following command:

 python -m pip install pip==<previous version>
dimi_mel
  • 1
  • 2
0

in one case, from your python file do this edit to your IMPORT

--import [MODULE]
++from [MODULE_NAME] import [MODULE]
Simas Joneliunas
  • 2,890
  • 20
  • 28
  • 35
-1

Had the same problem. I've managed to fix it by reinstalling pip in place, using combination the other answers:

python -m pip install -U --force-reinstall pip