python - py2app、pycrypto、aes 未找到

标签 python openssl aes py2app

这是我第一次使用 py2app。 我已经设法从我的 python 脚本中制作了一个包(?)/app,但正如本主题 Include openssl in app 中所述openssl 不包含在我的应用程序中,但我不明白 pycrypto 是否也不能包含或者我是否做错了。 因此,当我尝试执行我的应用程序时,我收到一个 ImportError 告诉我找不到 aes。

main[15198]:   File "/Users/lumy-meludia/Meludia/clients/campaign_manager_gui/dist/main.app/Contents/Resources/__boot__.py", line 351, in <module>
main[15198]:     _run()
main[15198]:   File "/Users/lumy-meludia/Meludia/clients/campaign_manager_gui/dist/main.app/Contents/Resources/__boot__.py", line 336, in _run
main[15198]:     exec(compile(source, path, 'exec'), globals(), globals())
main[15198]:   File "/Users/lumy-meludia/Meludia/clients/campaign_manager_gui/dist/main.app/Contents/Resources/main.py", line 16, in <module>
main[15198]:     from campaign_manager_gui.client_campaign.CampaignClient import run
main[15198]:   File "campaign_manager_gui/client_campaign/CampaignClient.pyc", line 21, in <module>
main[15198]:   File "pymelu_client/client/ClientNetwork.pyc", line 13, in <module>
main[15198]:   File "OpenSSL/__init__.pyc", line 8, in <module>
main[15198]:   File "OpenSSL/rand.pyc", line 11, in <module>
main[15198]:   File "OpenSSL/_util.pyc", line 4, in <module>
main[15198]:   File "cryptography/hazmat/bindings/openssl/binding.pyc", line 89, in __init__
main[15198]:   File "cryptography/hazmat/bindings/openssl/binding.pyc", line 113, in _ensure_ffi_initialized
main[15198]:   File "cryptography/hazmat/bindings/utils.pyc", line 47, in build_ffi
main[15198]: ImportError: No module named aes

我尝试将 pycrypto 添加到我的安装文件中

APP = ["campaign_manager_gui/gui/main.py"]
DATA_FILES = ['campaign_manager_gui/gui', 'campaign_manager_gui/client_campaign',]
OPTIONS = {'argv_emulation': True, 'includes': ['pycrypto']}
setup(
  app=APP,
  data_files=DATA_FILES,
  options={'py2app': OPTIONS},
  setup_requires=['py2app'],
)

但是py setup.py py2app的结果给了我

running py2app
creating /Users/lumy-meludia/Meludia/clients/campaign_manager_gui/build/bdist.macosx-10.9-x86_64/python2.7-standalone/app
creating /Users/lumy-meludia/Meludia/clients/campaign_manager_gui/build/bdist.macosx-10.9-x86_64/python2.7-standalone/app/collect
creating /Users/lumy-meludia/Meludia/clients/campaign_manager_gui/build/bdist.macosx-10.9-x86_64/python2.7-standalone/app/temp
creating build/bdist.macosx-10.9-x86_64/python2.7-standalone/app/lib-dynload
creating build/bdist.macosx-10.9-x86_64/python2.7-standalone/app/Frameworks
/Users/lumy-meludia/.pyenv/versions/env_2.7/lib/python2.7/site-packages/modulegraph/find_modules.py:258: UserWarning: No module named pycrypto
  warn("No module named %s"%(mod,))
*** using recipe: virtualenv ***
*** using recipe: ftplib ***
*** using recipe: lxml ***
*** using recipe: xml ***
*** using recipe: sip ***
*** using recipe: pydoc ***
*** using recipe: ctypes ***
*** filtering dependencies ***
1191 total
46 filtered
115 orphaned
1145 remaining
*** create binaries ***
[...]

你能帮我将 pycrypto 和 Openssl 包含在我的应用程序中吗?

最佳答案

经过几天的寻找,我在 stackoverflow 上找到了一篇文章,其中解释了 py2app 不会采用来自/usr/lib 或/System 的库 Include openssl in app这是有逻辑的理由的。

因此他们建议自己重新编译 OpenSSL 和其他依赖项,并且由于我使用的是 Mac,而不是 XCode 和 Mac 的专家,因此我认为这对我来说不是一个快速解决方案。

经过其他查看,我发现了 pyinstaller https://github.com/pyinstaller/pyinstaller/wiki其功能与 py2app 相同,但麻烦更少。

您只需确保所有软件包都安装在您的系统(或 virtualenv)上并且运行良好。

关于python - py2app、pycrypto、aes 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27826834/

相关文章:

python - 使用文件中的关键字和文件名创建关键字字典

python:仅覆盖抽象类中的一些方法

Python:导入 OpenSSL 时出错

linux - gcc .h 没有这样的文件或目录(openssl、anaconda、Ubuntu 18.04

encryption - AES 加密 16 字节无填充

c - C 中的 Libgcrypt 返回 42

Python:子串存在

python如何检查一个字符串是否是一个字符串列表的元素

c++ - Openssl aes.h [链接器错误] undefined reference

c# - AES 解密在中文语言环境中失败,出现无效字符错误