使用 Pipenv 安装包

Install package with Pipenv

我正在尝试在 virenv 中使用 Python 中的加密包,但 VsCode 错误是“没有具有此名称的模块:Crypt.py(script) 和 Pipfile 在同一个目录

...my direcotry > pipenv install cryptography 
....>

crypt.py

from cryptography.fernet import Fernet 
key = Fernet.generate_key()
print(key)

错误:

from cryptography.fernet import Fernet
ModuleNotFoundError: No module named 'cryptography'

pip文件:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
cryptography = "*"

[requires]
python_version = "3.8"

确保您 运行 python 在您使用 Pipenv 设置的虚拟环境中:

pipenv run python my_script.py