出现错误,使用pyinstaller时没有名为“ cryptography”的模块

时间:2020-08-06 18:12:18

标签: python cryptography pyinstaller

我尝试使用pyinstall将py转换为exe,但出现此错误,请帮助 我不知道为什么此代码可以在SV代码中运行

1011.py

import base64
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from cryptography.fernet import Fernet

def keyy():
    password1 = 'test'
    password2 = password1.encode()
    salt = b'\x18\xa0V\xcc\2\xddZ\xd6\xb6\xbf\xb0\xcecq\x30eZ'
    kdf = PBKDF2HMAC(algorithm = hashes.SHA256(), length = 32, salt = salt, iterations = 100000, backend = default_backend())
    return base64.urlsafe_b64encode(kdf.derive(password2))

def Encrypt(text):
    key = keyy()
    encoded = text.encode()
    f = Fernet(key)
    return f.encrypt(encoded)

a = input()
print(Encrypt(a))

终端

Traceback (most recent call last):
File "1011.py", line 2, in <module>
.uleNotFoundError: No module named 'cryptography'
[3408] Failed to execute script 1011

1 个答案:

答案 0 :(得分:0)

我只是修复了它,然后尝试将PyInstaller安装到我的Conda上,然后它的工作

PyTutorials(Youtube Chanel)说:

您是否有机会在一次安装中安装了PyInstaller? 不同安装的Python中的Python和加密 偶然?如果是这样,PyInstaller在以下情况下看不到加密 包装。