Python到可执行文件-无法导入模块
在Win10 x64上运行Python 3.5。已经尝试过py2exe、PyInstaller和cxfreeze。它们都运行并生成一个.exe。但是没有一个.exe在运行时会在出现错误后立即关闭它们。它们都有警告日志,其中包含大量无法正确导入的必需模块 PyInstaller:Python到可执行文件-无法导入模块,python,exe,Python,Exe,在Win10 x64上运行Python 3.5。已经尝试过py2exe、PyInstaller和cxfreeze。它们都运行并生成一个.exe。但是没有一个.exe在运行时会在出现错误后立即关闭它们。它们都有警告日志,其中包含大量无法正确导入的必需模块 PyInstaller: missing module named time.time - imported by time, http.cookies ... missing module named urllib.proxy_bypass -
missing module named time.time - imported by time, http.cookies
...
missing module named urllib.proxy_bypass - imported by urllib, requests.compat
...
cxfreeze:
Missing modules:
? Cookie imported from requests.compat
? Image imported from openpyxl.drawing.image
? OpenSSL.SSL imported from requests.packages.urllib3.contrib.pyopenssl
? StringIO imported from requests.compat, requests.packages.urllib3.packages.six
...
PyInstaller还抛出依赖性错误,例如缺少“api-ms-win-crt-RUNTION-l1-1-0.dll”。VisualC++和No.55-2015都安装了VisualStudio社区15。
证明这是一个OpenPyxL的问题,它是一个导入的模块。
PyInstaller 3.0 Python 3.5 on Win10 x64 with Visual Studio Community 15
works for me. I run pyinstaller --onefile file_script.py
in windows path i have the folowing
C:\Python35;
C:\Python35\Scripts;
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin;
下载存储库的副本,使用上一个URL中所做的更改,然后从中安装openpyxl(使用'pip install-e(openpyxldirectory))允许生成可工作的.exe我对py2exe有一些经验。你能告诉我你遇到了什么错误吗?@CrakC我认为py2exe不支持python 3.5,因为它一直试图打开一个3.4版本的文件。另外,在安装时(不是通过pip),它让我指向我的python 3.4目录,在找不到目录时退出。另外,Win10是一个新的操作系统,在这种情况下,兼容性问题非常明显。从3.5迁移到3.4有问题吗?
FileNotFoundError:[Errno 2]没有这样的文件或目录:“…Python\\Python35\\lib\\site packages\\py2exe\\run-py3.5-win-amd64.exe”
这是特定错误。在该位置,只有run-py3.4exists@CrakC我不知道我在迁移到3.4时是否遇到了问题-会有什么问题?我立即注意到我没有在C root上安装Python(我喜欢保持干净!),你认为这会导致问题吗,脚本试图查找与其所在位置相关的文件?@Prof,是的,很可能就是这样。你知道一种无痛的方法来更改安装目录吗?我想卸载和重新安装会丢失我所有的自定义模块?@Prof你可以随时移动python文件夹,但是你可以需要在系统属性中更新windows路径。在移动和更改路径后仍然会出现相同的错误。为了澄清,我正在做的是打开一个命令行并键入:python-m PyInstaller--onefile 123.py