Python - Trouble Shooting

Last Updated: 2024-01-20

TypeError: 'xxx' object is not callable


TypeError: 'dict' object is not callable


TypeError: 'module' object is not callable


May accidentally added ()


Remove the ()

fatal error: Python.h: No such file or directory

sudo apt-cache search python
sudo apt-get install python2.7-dev

Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS


$ apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libsqlite3-dev


$ yum install zlib-devel bzip2-devel sqlite sqlite-devel openssl-devel

And re-configure and re-make Python

$ configure; make; sudo make install
Installing collected packages: setuptools, pip
Successfully installed pip-7.1.2 setuptools-18.2

If libssl-dev fails:

$ sudo apt-get install libssl-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libssl-dev : Depends: libssl1.0.0 (= 1.0.1f-1ubuntu2) but 1.0.1f-1ubuntu2.8 is to be installed
              Recommends: libssl-doc but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

add version:

$ sudo apt-get install libssl1.0.0=1.0.1f-1ubuntu2
$ sudo apt-get install libssl-dev

NameError: name 'reduce' is not defined

It was moved to functools.

OSError: [Errno 8] Exec format error

This can happen if there is no shebang line at the top of the shell script and you are trying to execute the script directly.