0

I installed M2Crypto as per this guide: https://github.com/dsoprea/M2CryptoWindows

I run this command:

C:\grr-build\M2Crypto-master>C:\Python27\python.exe setup.py install

Then, I got this which confirms to me that the M2Crypto module has been successfully installed:

Installed c:\python27\lib\site-packages\m2crypto-0.22.3-py2.7-win-amd64.egg
Processing dependencies for M2Crypto==0.22.3
Finished processing dependencies for M2Crypto==0.22.3 

When I try to test the import M2Crypto in a python script, when I run the test script, I get this error:

Traceback (most recent call last): File "C:\Users\Administrator.e-Administrator\Desktop\Pytest\test.py", line 2, in import M2Crypto File "C:\Python27\lib\site-packages\M2Crypto__init__.py", line 24, in import ASN1 File "C:\Python27\lib\site-packages\M2Crypto\ASN1.py", line 12, in import BIO File "C:\Python27\lib\site-packages\M2Crypto\BIO.py", line 221, in class CipherStream(BIO): File "C:\Python27\lib\site-packages\M2Crypto\BIO.py", line 227, in CipherStrea m SALT_LEN = m2.PKCS5_SALT_LEN AttributeError: 'module' object has no attribute 'PKCS5_SALT_LEN'

Knowing that I skipped one step in the guide given in the link above which was about installing M2Crypto patch because I did not get how to perform it.

Can you please help me? What is the problem with M2Crypto and how to solve it?

user2192774
  • 3,807
  • 17
  • 47
  • 62

1 Answers1

1

"AttributeError: 'module' object has no attribute 'PKCS5_SALT_LEN'" was a bug in M2Crypto 0.22.3, and has been fixed in in 0.22.4 (https://github.com/martinpaljak/M2Crypto/issues/60). Just upgrade M2Crypto and the problem ought to be gone:

$ pip uninstall M2Crypto
Uninstalling M2Crypto-0.22.3:
  ...
Proceed (y/n)? y
  Successfully uninstalled M2Crypto-0.22.3
$ pip install M2crypto  
Collecting M2crypto
Downloading M2Crypto-0.22.5.tar.gz (80kB)
...
Successfully installed M2crypto-0.22.5

Before the upgrade, running import M2Crypto gave the error as reported in the question; after the upgrade the import succeeded without any problems.

Rob W
  • 341,306
  • 83
  • 791
  • 678