【问题标题】:Python 2.7 The 'packaging' package is required; normally this is bundled with this packagePython 2.7 需要“打包”包;通常这与此软件包捆绑在一起
【发布时间】:2016-07-08 01:36:42
【问题描述】:

我预计这与加密模块有关,但我不确定。

Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "c:\python27\lib\site-packages\PyInstaller-2.1-py2.7.egg\PyInstaller\load
er\pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "C:\Python34\Stuff\Encrypt\build\encrypt\out00-PYZ.pyz\pkg_resources", li
ne 68, in <module>
  File "C:\Python34\Stuff\Encrypt\build\encrypt\out00-PYZ.pyz\pkg_resources.exte
rn", line 60, in load_module
ImportError: The 'packaging' package is required; normally this is bundled with
this package so if you get this warning, consult the packager of your distributi
on.

来源:

import os, sys, getpass, time
from cryptography.fernet import Fernet
from tqdm import tqdm
from time import gmtime, strftime
import subprocess
name = getpass.getuser()
print strftime("%Y-%m-%d %I:%M:%S")
print "NOTE: Encrypting will delete all data in either .txt, so please save the data."
print "-------------------------------------------------------------------------------"
def copy2clip(txt):
   cmd='echo '+txt.strip()+'|clip'
   return subprocess.check_call(cmd, shell=True)
def delete():
    try:
        os.remove("key.txt")
        os.remove("Encryption.txt")
    except:
        print "Error, files not deleted."
def encrypt():
    input = raw_input("Please enter what you want to be encrypted: ")
    for i in tqdm(range(100)):
        time.sleep(0.01)
    key = Fernet.generate_key()
    cipher_suite = Fernet(key)
    cipher_text = cipher_suite.encrypt(input)
    plain_text = cipher_suite.decrypt(cipher_text)
    time.sleep(1)
    print "Encryption completed..."
    #save

    f = open("encryption.txt", "w")
    f.write(cipher_text)
    f.close()
    time.sleep(1)
    print "Encryption data saved to encryption.txt and copied to clipboard..."
    copy2clip(cipher_text)

    d = open("key.txt", "w")
    d.write(key + "\n\n")
    d.close()
    time.sleep(1)
    print "Key data saved to key.txt..."
    time.sleep(5)
while True:
    encrypt()
    os.system('cls')
    print strftime("%Y-%m-%d %I:%M:%S")
    print "NOTE: Encrypting will delete all data in either .txt, so please save the data."
    print "-------------------------------------------------------------------------------"

time.sleep(5)

我注意到一个名为 cryptography.hazmat.bindings._padding.pyd 的文件,并且我看到有人在使用它时遇到了问题。我需要编辑钩子还是什么?

【问题讨论】:

    标签: python cryptography pyinstaller


    【解决方案1】:

    试试这个

    pip uninstall setuptools
    pip install setuptools==19.2
    

    【讨论】:

      【解决方案2】:

      使用最新版本的 pyinstaller 更新,现在可以正常工作了。

      【讨论】:

      • 您能否进一步解释一下您的解决方案?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-18
      • 1970-01-01
      • 2010-12-25
      • 1970-01-01
      • 1970-01-01
      • 2016-03-26
      • 2023-03-31
      相关资源
      最近更新 更多