How to get Python m2Crypto to work with virtualenv?

10,875

Solution 1

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.

Solution 2

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
Share:
10,875
bdd
Author by

bdd

Updated on June 04, 2022

Comments

  • bdd
    bdd about 2 years

    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