pip list – exits with error “TypeError: ‘module’ object is not callable”
Issue:
# pip list
Traceback (most recent call last):
File “/app/python/2.7.16/bin/pip”, line 11, in <module>
sys.exit(main())
TypeError: ‘module’ object is not callable
Resolution:
# python -m pip install --upgrade pip
Where option “-m” – run library module as a script (terminates option list)
Explanation:
A broken pip installation can cause this issue. By reinstalling the pip will resolve the problem.
If you have a custom compiled python (not the one installed via system packages) make sure you take an archival backup using “cp -ar <source> <destination>” before making any changes or upgrades. This helps you to safely roll back if you have any issues with upgrades or patches.
Following is the upgrade log:
# python -m pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 18.1
Uninstalling pip-18.1:
Successfully uninstalled pip-18.1
Successfully installed pip-19.3.1