Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Python m2Crypto to work with virtualenv?

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
like image 762
bdd Avatar asked Mar 27 '12 15:03

bdd


2 Answers

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.

like image 195
Seb Avatar answered Oct 07 '22 17:10

Seb


My solution to pip install M2Crypto in my VirtualEnv on my Mac with OSX was as follows:

A: Exit the virtualenv

B: Download Swig using the below link and following the INSTALL text document instructions on installing it.

http://sourceforge.net/projects/swig/?source=dlp

C: Install PCRE developer version as well because Swig needed it to run. Follow the below link and the INSTALL text document instructions on installing it.

http://sourceforge.net/projects/pcre/?source=dlp

D: go back into my virtualenv that I was trying to install M2Crypto into in the first place, activate the virtualenv, and run:

pip install M2Crypto
like image 23
Aaron Lelevier Avatar answered Oct 07 '22 15:10

Aaron Lelevier