Python, Django with PyCharm. Message error: "No module named M2Crypto" How resolve?
Question: I received this message: "No module named M2Crypto" I have already install
M2Crypto with the command "pip install M2Crypto" and when I re-run it, I got
the message: "Requirement already satisfied"

What's the problem with M2Crypto?

Thanks

ps: I use Linux: 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:12:00 UTC 2013
i686 i686 i686 GNU/Linux, Pycharm and Python2.7 (/usr/bin/python2.7)

Maybe some interpreter option in PyCharm configuration for running the
project?


Answer: First of all, verify that the **version of pip** is in line with your
interpreter. So for python2.7,

    
    
    pip --version 
    

should print something like

    
    
    pip 6.0.8 from /usr/local/lib/python2.7/dist-packages (python 2.7)
    

depending on how you've installed it. The important part is in the end, where
your interpreter ("python 2.7") should be shown.

Once you're sure to have the right pip-version, ensure your **package is
correctly installed**. It should usually be installed in the directory printed
out previously by pip (e.g. /usr/local/lib/python2.7/dist-packages/).

Assume you've already done this, **what else** can go wrong to make your
interpreter not finding the 'M2Crypto' package?

python uses the `PYTHONPATH` environment variable for module lookups. So,
there's the possibility, that your `PYTHONPATH` variable has been changed. Try
running your program by adding the above-mentioned path to `PYTHONPATH` and
either exporting it before running your webserver:

    
    
    export PYTHONPATH=/usr/local/lib/python2.7/dist-packages/:$PYTHONPATH
    # run your server here
    

or by prepending the same variable to your command:

    
    
    PYTHONPATH=/usr/local/lib/python2.7/dist-packages/:$PYTHONPATH python <run-stuff-here>
    

This should make your program find the M2Crypto module.

