0

I used to inuput the command pip3 install module_name to install any module and it was working. But suddenly I have the following error when I try to install something.

Traceback (most recent call last):
 File "/Library/Frameworks/Python.framework/Versions/3.7/bin/pip", line 10, in <module>
   sys.exit(main())
TypeError: 'module' object is not callable

Do somebody know why this error occurs and how I can solve it please?

delalma
  • 838
  • 3
  • 12
  • 24

1 Answers1

1

You want to use python -m pip install <module> because the python command will leverage a specific interpreter. However, pip by itself could point to any number of pip binaries, which could point to unknown interpreters. So, best thing to do is to specify the interpreter.

Specifically, the -m flag says "I want to call a module from the python I have specified." pip is not the only module you can do this with:

python -m timeit
python -m zipfile
python -m pip

You can check where pip is pointing by using the -V flag:

python -m pip -V
pip 19.2.2 from /Users/mm92400/anaconda3/lib/python3.6/site-packages/pip (python 3.6)
C.Nivs
  • 12,353
  • 2
  • 19
  • 44