How to get Python m2Crypto to work with virtualenv?

bdd picture bdd · Mar 27, 2012 · Viewed 10.7k times · Source

I'm trying to install M2Crypto so that I can generate pkey in my web app. My hosting requirements dictate that I must use pip to install any dependencies. Installing m2crypto at the system level is not an option for me. I'm using Mint 12 in development and will be deploying to heroku.

error: command 'swig' failed with exit status 1 looks like the issue, but google was no help. Thoughts?

Dump

Downloading/unpacking m2crypto
  Downloading M2Crypto-0.21.1.tar.gz (413Kb): 413Kb downloaded
  Running setup.py egg_info for package m2crypto

Installing collected packages: m2crypto
  Running setup.py install for m2crypto
    building 'M2Crypto.__m2crypto' extension
    swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
    swig -python -I/usr/include/python2.7 -I/usr/include -includeall -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
    unable to execute swig: No such file or directory
    error: command 'swig' failed with exit status 1
    Complete output from command /home/bob/.virtualenvs/my_app/bin/python -c "import setuptools;__file__='/home/bob/.virtualenvs/my_app/build/m2crypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-O1V45n-record/install-record.txt --install-headers /home/bob/.virtualenvs/my_app/include/site/python2.7:
    running install
running build
(....clip...)
swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
swig -python -I/usr/include/python2.7 -I/usr/include -includeall -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
unable to execute swig: No such file or directory
error: command 'swig' failed with exit status 1

----------------------------------------
Command /home/bob/.virtualenvs/my_app/bin/python -c "import setuptools;__file__='/home/bob/.virtualenvs/my_app/build/m2crypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-O1V45n-record/install-record.txt --install-headers /home/bob/.virtualenvs/my_app/include/site/python2.7 failed with error code 1 in /home/bob/.virtualenvs/my_app/build/m2crypto

Answer

Seb picture Seb · Apr 30, 2012

Your problem has nothing to do with virtualenv. You just don't have swig installed.

Install swig using your distribution's package manager and try reinstalling M2Crypto in the virtualenv.