Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

pip

ubuntu

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

like image 327
Israel Obando Cisneros Avatar asked Oct 15 '19 03:10

Israel Obando Cisneros


People also ask

How do you fix a module object is not callable?

The Python "TypeError: 'module' object is not callable" occurs when we import a module as import some_module but try to call it as a function or class. To solve the error, use dot notation to access the specific function or class before calling it, e.g. module. my_func() .

How do you call a module object in Python?

You can use the functions such as factorial(), floor() and fabs() within this module. But if you try using a function with name math(), the compiler will be confused. It will throw an error called TypeError 'module' object is not callable in Python.


2 Answers

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

like image 122
Hyrial Avatar answered Sep 18 '22 05:09

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()) 
like image 36
i_am_deesh Avatar answered Sep 18 '22 05:09

i_am_deesh