I made script that involves pycryptodome
library. Some time ago (like 3 days ago) it worked fine, but now when I try to run it, I get this error:
Traceback (most recent call last):
File "C:\0002_Programowanie\0001_MAIN\0000_APP\lockify\src\app\passwords\main.py", line 2, in <module>
from encrypt import Encrypter
File "C:\0002_Programowanie\0001_MAIN\0000_APP\lockify\src\app\passwords\encrypt.py", line 1, in <module>
from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto'
I've already tried: reintstalling module, installing different version of module (3.19), running script from shell with python
and python3
command, clearing pip's cache. Nothing worked!
I would really appreciate if you could help me solve it. I need this module to work properly.
Here is code of main.py:
import argparse
from encrypt import Encrypter
from decrypt import Decrypter
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--text", type=str, required=True, default=None, help="Text to encrypt or decrypt")
parser.add_argument("-p", "--password", type=str, required=True, help="Password to use for encryption/decryption")
parser.add_argument("-o", "--operation", type=str, choices=["encrypt", "decrypt"], required=True, help="Operation to perform (encrypt or decrypt)")
args = parser.parse_args()
print(args)
(Encrypter and Decrypter are not being used for now, but will be in a future)
passwords
├─── encrypt.py
├─── decrypt.py
├─── main.py
pip list
output:Package Version
------------------------- ---------
altgraph 0.17.3
bcrypt 4.0.1
blinker 1.6.3
certifi 2023.7.22
chardet 5.2.0
charset-normalizer 3.2.0
click 8.1.7
colorama 0.4.6
customtkinter 5.2.0
darkdetect 0.8.0
decorator 4.4.2
EasyProcess 1.1
enigmacrypt 0.0.8
entrypoint2 1.1
Flask 3.0.0
Flask-Login 0.6.3
Flask-SQLAlchemy 3.1.1
greenlet 3.0.1
idna 3.4
imageio 2.31.5
imageio-ffmpeg 0.4.9
itsdangerous 2.1.2
Jinja2 3.1.2
loguru 0.6.0
MarkupSafe 2.1.3
MouseInfo 0.1.3
moviepy 1.0.3
mss 9.0.1
Naked 0.1.32
natsort 8.4.0
notify-py 0.3.42
numpy 1.25.2
opencv-python 4.8.0.74
pefile 2023.2.7
Pillow 10.0.0
pip 24.0
plyer 2.1.0
proglog 0.1.10
PyAutoGUI 0.9.54
pycryptodome 3.20.0
pycryptodome-test-vectors 1.0.13
PyGetWindow 0.0.9
pyinstaller 5.13.0
pyinstaller-hooks-contrib 2023.6
PyMsgBox 1.0.9
pynotify 0.1.1
pyperclip 1.8.2
PyQt5 5.15.10
PyQt5-Qt5 5.15.2
PyQt5-sip 12.13.0
PyRect 0.2.0
pyscreenrec 0.4
pyscreenshot 3.1
PyScreeze 0.1.29
pytweening 1.0.7
pywin32-ctypes 0.2.2
PyYAML 6.0.1
qt-material 2.14
requests 2.31.0
setuptools 69.0.0
shellescape 3.8.1
SQLAlchemy 2.0.22
tqdm 4.66.1
ttkbootstrap 1.10.1
typing_extensions 4.7.1
urllib3 2.0.4
Werkzeug 3.0.1
wheel 0.43.0
win32-setctime 1.1.0
As it turns out there were kind of two interpreters on my PC. Local and Global (at least that's what they've been called in VSCode). Running code through the Local interpreter raised this error, though while running it from the Global one did not cause any problem.
I set the VSCode to work only with the Global one because when I was at the Local one it was showing me inside of the code (before even running) that there is no Crypto module even though I've checked whether it's installed. After switching to the Global interpreter it worked fine until I needed to run it not through the VSCode debugger, but with python
command via Shell. Then (I guess) it was constantly using the Local interpreter which caused this error.
I've simply checked the path to this interpreter marked as Local (it was C:\msys64\mingw64\bin
) and just deleted all the files associated with Python. It works and I don't see any complications. Hope that helps anyone else