How do I install M2Crypto on Ubuntu?

Daryl Spitzer picture Daryl Spitzer · Jun 24, 2010 · Viewed 37.2k times · Source

I'm trying to build and install M2Crypto on Ubuntu 10.04 LTS. I downloaded and untarred M2Crypto-0.20.2.tar, and from the M2Crypto-0.20.2 directory I tried python setup.py build. I got an error because I don't have swig. So I ran sudo apt-get install swig. Then I tried python setup.py build again and got:

/usr/lib/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'test_suite'
  warnings.warn(msg)
running build
running build_py
running build_ext
building 'M2Crypto.__m2crypto' extension
swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
swig -python -I/usr/include/python2.6 -I/usr/include -includeall -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
SWIG/_bio.i:64: Warning(454): Setting a pointer/reference variable may leak memory.
SWIG/_rand.i:19: Warning(454): Setting a pointer/reference variable may leak memory.
SWIG/_evp.i:156: Warning(454): Setting a pointer/reference variable may leak memory.
SWIG/_dh.i:36: Warning(454): Setting a pointer/reference variable may leak memory.
SWIG/_rsa.i:43: Warning(454): Setting a pointer/reference variable may leak memory.
SWIG/_dsa.i:31: Warning(454): Setting a pointer/reference variable may leak memory.
SWIG/_ssl.i:207: Warning(454): Setting a pointer/reference variable may leak memory.
SWIG/_x509.i:313: Warning(454): Setting a pointer/reference variable may leak memory.
SWIG/_pkcs7.i:42: Warning(454): Setting a pointer/reference variable may leak memory.
SWIG/_pkcs7.i:42: Warning(454): Setting a pointer/reference variable may leak memory.
SWIG/_util.i:9: Warning(454): Setting a pointer/reference variable may leak memory.
SWIG/_ec.i:111: Warning(454): Setting a pointer/reference variable may leak memory.
SWIG/_engine.i:162: Warning(454): Setting a pointer/reference variable may leak memory.
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -I/usr/include -I/home/dspitzer/M2Crypto-0.20.2/SWIG -c SWIG/_m2crypto_wrap.c -o build/temp.linux-i686-2.6/SWIG/_m2crypto_wrap.o -DTHREADING
SWIG/_m2crypto_wrap.c:126:20: error: Python.h: No such file or directory
SWIG/_m2crypto_wrap.c:757: error: expected ‘)’ before ‘*’ token
SWIG/_m2crypto_wrap.c:781: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token

...and so on.

Has anyone succeeded in doing this?

Update: I changed the title, since it didn't occur to me that M2Crypto would be a pre-build Ubuntu package.

Answer

ʇsәɹoɈ picture ʇsәɹoɈ · Jun 24, 2010

You probably need to install the python development packages:

sudo apt-get install python-dev

Better yet, don't bother building m2crypto yourself. It's already in the Ubuntu repositories as a fully supported package. This way, you'll get automatic updates through the same means as the rest of your Ubuntu system:

sudo apt-get install python-m2crypto