Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 365
s g Avatar asked May 07 '26 19:05

s g


1 Answers

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.

like image 56
s g Avatar answered May 09 '26 09:05

s g



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!