When I need to import Crypto in Python3.10 like this in macOS 13.4 with M1 chip:
from Crypto.Cipher import PKCS1_v1_5 as Cipher_pksc1_v1_5
from Crypto.PublicKey import RSA
def print_hi(name):
print(f'Hi, {name}')
if __name__ == '__main__':
print_hi('PyCharm')
shows:
Unresolved reference 'Crypto'
I have already tried to install pycryptodome
like this:
pdm add pycryptodome
still could not fixed this problem. What should I do to fixed this issue?This is the pyproject.toml
:
[project]
name = ""
version = ""
description = ""
authors = [
{name = "JiangXiaoqiang", email = "[email protected]"},
]
dependencies = [
"pycryptodome>=3.19.0",
]
requires-python = ">=3.10"
readme = "README.md"
license = {text = "MIT"}
this is the pdm list
output:
> pdm list|grep py
Inside an active virtualenv /Users/xiaoqiangjiang/source/dolphin/visa/venv, reusing it.
Set env var PDM_IGNORE_ACTIVE_VENV to ignore it.
│ rdpywheel │ 0.1.16 │ │
│ python-dateutil │ 2.8.2 │ │
│ pyasn1 │ 0.5.0 │ │
│ pycryptodome │ 3.19.0 │ │
│ openpyxl │ 3.1.2 │ │
│ pycparser │ 2.21 │ │
│ numpy │ 1.26.1 │ │
│ pyOpenSSL │ 21.0.0 │ │
│ python-dotenv │ 1.0.0 │ │
│ pycurl │ 7.45.2 │ │
│ brotlipy │ 0.7.0 │ │
│ pyparsing │ 3.0.9 │ │
this is the UI about how I facing issue:
this is the python which output:
> which python
/Users/xiaoqiangjiang/PycharmProjects/pythonLearn/venv/bin/python
and this is the pdm info output:
> pdm info
PDM version:
2.10.1
Python Interpreter:
/Users/xiaoqiangjiang/PycharmProjects/pythonLearn/.venv/bin/python (3.10)
Project Root:
/Users/xiaoqiangjiang/PycharmProjects/pythonLearn
Local Packages:
Instead of using from Crypto.Cipher import PKCS1_v1_5 as Cipher_pksc1_v1_5, try the more explicit import: