pip3 "TypeError: 'module' object is not callable" after update

Question:

I am new in Python, I wanna install Jupyter Notebook in my console I enter the following:

pip3 install --upgrade pip 

after that I have a error to use pip3 install other library, the console print:

File "/usr/bin/pip3", line 11, in <module>
    sys.exit(main())
TypeError: 'module' object is not callable

I don’t know what I have to do.

I use sudo autoremove python3-pip after that I use sudo apt install python3-pip

Answers:

As seen here, you should be able to solve this by running the module from Python directly, i.e.

python -m pip install --upgrade pip
Answered By: Bram Vanroy

From the link by Bram, I just ran python3 -m pip uninstall pip, and it started to work again.

Answered By: Hyrial

The solution which worked for my situation is simply editing the pip3.8 file in the ubuntu environment.

Method1:

#!/path/to/.venv/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from pip._internal.main import main  # <--- look at this import statement! 

if __name__ == '__main__':
     sys.argv[0] = re.sub(r'(-script.pyw?|.exe)?$', '', sys.argv[0])
     sys.exit(main())

method2:

The main function has to be imported or we can simply replace line

sys.exit(main())

As

sys.exit(main.main())
Answered By: i_am_deesh

Use this

python -m pip install –upgrade –user [name_of_your_package]

Answered By: Purushottam

In Windows edit C:ProgramDataAnaconda3Scriptspip-script.py and replace

# -*- coding: utf-8 -*-
import re
import sys
from pip._internal import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script.pyw?|.exe)?$', '', sys.argv[0])
    sys.exit(main())

Replace the last line with sys.exit(main.main()).

Answered By: Maddu Swaroop
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.