problems installing M2Crypto on Mint: follow-up

2020-06-23 07:57发布

问题:

I asked a question here regarding installing the M2Crypto python library in Mint. That question was answered successfully and I was able to build and install M2Crypto. However, I am not able to use it within Python. when I attempt to import the module, I get the following error:

>>> import M2Crypto
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/M2Crypto/__init__.py", line 22, in <module>
    import __m2crypto
ImportError: /usr/local/lib/python2.7/dist-packages/M2Crypto/__m2crypto.so: undefined symbol: SSLv2_method

If anyone know how to resolve this error, please let me know.

回答1:

It looks like it is a bug introduced in M2Crypto 0.21.1, there is a patch here that correct the problem.

Maybe you could try to install an old version of M2Crypto (like the 0.20.1-1.1) or apply the patch manually with the patch command.



回答2:

After two years the problem in m2crypto0.21.1 still exists, so here is a note for Ubuntu users. If you're not using virtualenv, you can easily fix it by installing m2crypto from Ubuntu PPA instead of pip:

sudo pip uninstall m2crypto 
sudo apt-get install python-m2crypto

Seems like the problem is fixed in the PPA, but not in the project's repo. At least it worked for me at Ubuntu 12.04.



回答3:

To expand the answer above:

This is a bug in M2Crypto 0.21.1. It has to do with the fact that SSLv2 was removed from OpenSSL on many platforms on the grounds of it being too insecure, notably Debian [1] and Ubuntu.

The removal is not detected during compile. There is a widely available patch that fixes this. I incorporated this into the M2Crypto source code on Github.

You can use pip to install directly from the repository like so:

pip install -e git+https://github.com/Hypernode/m2crypto#egg=M2Crypto

For those who want to inspect the (much published) patch that fixes this: b432d36

Edit: moved to another location