当我需要在MacOS 13.4中使用M1芯片在Python 3.10中导入Crypto时:
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')
字符串
显示:
Unresolved reference 'Crypto'
型
我已经试过像这样安装pycryptodome
:
pdm add pycryptodome
型
仍然无法修复此问题。我应该如何修复此问题?这是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"}
型
这是pdm list
输出:
> 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 │ │
型
这是关于我如何面对问题的UI:
的数据
这是python的输出:
> which python
/Users/xiaoqiangjiang/PycharmProjects/pythonLearn/venv/bin/python
型
这是pdm信息输出:
> 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:
型
1条答案
按热度按时间r55awzrz1#
不要使用from Crypto.Cipher import PKCS 1_v1_5 as Cipher_pksc1_v1_5,尝试更显式的导入:
字符串