Can't install python module "pycrypto" on Debian lenny

alex CSD picture alex CSD · Oct 27, 2011 · Viewed 15.2k times · Source

I tried to install pycrypto module by downloading the source code and executing the following command python setup.py install, then an error came

running install
running build
running build_py
running build_ext
warning: GMP library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Hash.MD2' extension
gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.5 -c src/MD2.c -o build/temp.linux-x86_64-2.5/src/MD2.o
src/MD2.c:31:20: error: Python.h: No such file or directory
src/MD2.c:118: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
In file included from src/MD2.c:134:
src/hash_template.c:42: error: expected specifier-qualifier-list before 'PyObject_HEAD'
src/hash_template.c:46: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PyTypeObject'
src/hash_template.c: In function 'newALGobject':
src/hash_template.c:55: warning: implicit declaration of function 'PyObject_New'
src/hash_template.c:55: error: expected expression before 'ALGobject'
src/hash_template.c:55: warning: assignment makes pointer from integer without a cast
src/hash_template.c: At top level:
src/hash_template.c:62: error: expected ')' before '*' token
src/hash_template.c:77: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
src/hash_template.c:96: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
src/hash_template.c:108: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
src/hash_template.c:143: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
src/hash_template.c:160: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ALG_methods'
src/hash_template.c:169: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
src/hash_template.c:178: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ALGtype'
src/hash_template.c:203: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
src/hash_template.c:237: error: array type has incomplete element type
src/hash_template.c:238: error: 'PyCFunction' undeclared here (not in a function)
src/hash_template.c:238: error: expected '}' before 'ALG_new'
src/hash_template.c: In function 'initMD2':
src/hash_template.c:254: error: 'PyObject' undeclared (first use in this function)
src/hash_template.c:254: error: (Each undeclared identifier is reported only once
src/hash_template.c:254: error: for each function it appears in.)
src/hash_template.c:254: error: 'm' undeclared (first use in this function)
src/hash_template.c:256: error: 'ALGtype' undeclared (first use in this function)
src/hash_template.c:256: error: 'PyType_Type' undeclared (first use in this function)
src/hash_template.c:257: warning: implicit declaration of function 'Py_InitModule'
src/hash_template.c:260: error: 'o' undeclared (first use in this function)
src/hash_template.c:260: warning: implicit declaration of function 'PyInt_FromLong'
src/hash_template.c:260: warning: implicit declaration of function 'PyDict_SetItemString'
src/hash_template.c:260: warning: implicit declaration of function 'PyModule_GetDict'
src/hash_template.c:260: warning: implicit declaration of function 'Py_DECREF'
src/hash_template.c:263: warning: implicit declaration of function 'PyErr_Occurred'
src/hash_template.c:264: warning: implicit declaration of function 'Py_FatalError'
error: command 'gcc' failed with exit status 1

Which means that he didn't find the Python.h. I searched online for this error and it seems that by installing the python header file the problem will be solved, but my Debian lenny came with anther error.

apt-get install python2.6-dev

and error :

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package python2.6-dev

Answer

Flimzy picture Flimzy · Oct 27, 2011

Don't install it from source. Install the Debian package instead:

aptitude install python-crypto

And to install the python dev files (which you won't need anyway if you follow my above advice):

aptitude install python-dev