Question

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
Was it helpful?

Solution

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.

OTHER TIPS

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

It looks like the error message is saying swig cannot be found. Is swig in your virtualenv, and in your path?

Also, to get M2Crypto to work, you've going to need access to the OpenSSL installation. If you can't link against the system's installation, you'll need to install it within your local virtualenv and point your link/library/include statements to use it.

Sorry it wasn't clearer. I think the problem is swig is not in your path. The error message says:

unable to execute swig: No such file or directory

What happens if you run 'swig' from the command prompt?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top