Search code examples
pythonm2crypto

Error in import M2Crypto


I need to use M2Crypto in my code. I downloaded the library as zip file from: https://github.com/martinpaljak/M2Crypto I unzipped the file. Inside the zipped file, I found folder named: M2Crypto, I copied it, and paste it in the same directory where my code .py file resides.

I added this line

from M2Crypto import RSA, X509

But I am getting this error:

import __m2crypto ImportError: No module named '__m2crypto'

Can you help me with the right way to import external library to python code? I am using windows system and I type the code using notepad++ so please, consider this in the answer.

EDIT: I use python 3.4


Solution

  • To install M2Crypto in windows, download the 2 files (x64 or x86 version depends on your system) from this link: https://github.com/dsoprea/M2CryptoWindows. Unzip the 2 files in the C: directory. Then, type this command:

    C:\Python27\Scripts>pip install --egg M2CryptoWin64
    

    Note: In the command, I used M2CryptoWin64 because this is what I installed. You might need to change this if you downloaded the x86 version.