Reputation: 439
When I try to execute a python program, I get this from terminal
Traceback (most recent call last):
File "ring.py", line 1, in <module>
import os, hashlib, random, crypto.PublicKey.RSA
ImportError: No module named crypto.PublicKey.RSA
I have no idea how to solve this and other questions have proven completely useless to my situation.
Is the module there but in the wrong place? Should I download modules from somewhere like for node.js? Or it's more like Java?
Upvotes: 26
Views: 100697
Reputation: 21
Uninstalling and reinstalling worked for me.
py -m pip uninstall pycryptodome
then
py -m pip install pycryptodome
Upvotes: 2
Reputation: 51
Install Pycryptodome using python3 -m pip install pycryptodome
. crypto.PublicKey.RSA
is not proper, instead try using from Crypto.PublicKey import RSA
.
Upvotes: 0
Reputation: 2915
The correct package to install is pycrypto.
pip install pycrypto
Should work on most platforms, otherwise get Pip from https://pip.pypa.io/en/stable/
Edit: As mentioned in the comments below, pip install pycryptodome
installs a newer, drop-in replacement for pycrypto and is the better option going forward.
Upvotes: 56
Reputation:
If you are using Python 3.7, it already exists. Just change the folder name in C:\Users\username\AppData\Local\Programs\Python\Python37\Lib\site-packages from crypto to Crypto
Upvotes: 14
Reputation: 363
Rename crypto directory under “Lib/site-packages” to Crypto, then importing will work.
Upvotes: 5
Reputation: 11134
Yes, you have to install it. Try this from terminal:
sudo apt-get install python-pip
pip install crypto
For mac
, try to use easy_install
.
sudo easy_install python-pip
pip install crypto
If crypto
is installed properly, import like below:
from Crypto.PublicKey import RSA
Upvotes: 1