Search code examples
pythonmacospython-2.7pycrypto

Why can't I import Crypto after installing pycrypto in Python?


On OSX 10.10, I'm getting 'ImportError: No module named Crypto' in Python 2.7.6 after installing the pycrypto module. I get the error when I run python in the terminal and try import Crypto.

I've installed via sudo pip install pycrypto and also tried installing from source from here: https://pypi.python.org/pypi/pycrypto. According to that site, there's a python setup.py test command (which runs fine for me), but it skips modules which aren't available, so I'm not sure if it's actually useful in this case.

The only thing I tried to do was find and compare to other packages in /Library/Python/2.7/site-packages... I noticed that the other packages (like Naked, PyYAML, and others) have directories whereas pycrypto just has an 'ASCII text' file (and no directory) according to the file pycrypto-2.6.1-py2.7.egg-info command. This scenario was after installing from source.

When installing from pip, I see that 'pycrypto-2.6.1-py2.7.egg-info' shows up as a directory, but there aren't any .py files in there.

I'm new to python and really at a loss. Any help is greatly appreciated.


Solution

  • The issue was not related to the .egg files - it was the Crypto directory itself.

    In my working solution I can't remember whether I used apt-get or whether I installed PyCrypto from source, but in the /Library/Python/2.7/site-packages directory I needed to rename the crypto directory to Crypto and everything worked fine.