我已经尝试使用py2exe(python 2.7.14)将我的python脚本编译为exe文件,但遗憾的是我在运行此代码时出现此错误: (在PyCharm中完美运行)
from distutils.core import setup
import py2exe
setup(console=['Dev.py'])
error: [Errno 2] No such file or directory: 'numpy-atlas.dll'
so i tried to fix it with this code:
from distutils.core import setup
import py2exe
import numpy
import os
import sys
def numpy_dll_paths_fix():
paths = set()
np_path = numpy.__path__[0]
for dirpath, _, filenames in os.walk(np_path):
for item in filenames:
if item.endswith('.dll'):
paths.add(dirpath)
sys.path.append(*list(paths))
numpy_dll_paths_fix()
setup(console=['dev.py'])
现在当我运行它时,我收到了这个错误:
您的可执行文件还依赖于未包含的这些dll, 您可能需要也可能不需要分发它们。 如果您分发任何许可证,请确保您拥有许可证 确保您不要分发属于操作系统的文件。
OLEAUT32.dll - C:\ WINDOWS \ system32 \ OLEAUT32.dll USER32.dll - C:\ WINDOWS \ system32 \ USER32.dll IMM32.dll - C:\ WINDOWS \ system32 \ IMM32.dll COMCTL32.dll - C:\ Python27 \ DLLs \ COMCTL32.dll WINMM.dll - C:\ WINDOWS \ system32 \ WINMM.dll USER32.dll - C:\ Python27 \ DLLs \ USER32.dll WS2_32.dll - C:\ Python27 \ DLLs \ WS2_32.dll ADVAPI32.dll - C:\ WINDOWS \ system32 \ ADVAPI32.dll mfc90.dll - C:\ Users \ Papom \ AppData \ Roaming \ Python \ Python27 \ site-packages \ Pythonwin \ mfc90.dll SHELL32.dll - C:\ Python27 \ DLLs \ SHELL32.dll msvcrt.dll - C:\ WINDOWS \ system32 \ msvcrt.dll WS2_32.dll - C:\ WINDOWS \ system32 \ WS2_32.dll GDI32.dll - C:\ WINDOWS \ system32 \ GDI32.dll COMDLG32.dll - C:\ Python27 \ DLLs \ COMDLG32.dll GDI32.dll - C:\ Python27 \ DLLs \ GDI32.dll ole32.dll - C:\ Python27 \ DLLs \ ole32.dll NETAPI32.dll - C:\ WINDOWS \ system32 \ NETAPI32.dll IMM32.dll - C:\ Python27 \ DLLs \ IMM32.dll KERNEL32.dll - C:\ WINDOWS \ system32 \ KERNEL32.dll OLEAUT32.dll - C:\ Python27 \ DLLs \ OLEAUT32.dll MSVCP90.dll - C:\ Python27 \ MSVCP90.dll KERNEL32.dll - C:\ Python27 \ DLLs \ KERNEL32.dll ADVAPI32.dll - C:\ Python27 \ DLLs \ ADVAPI32.dll VERSION.dll - C:\ WINDOWS \ system32 \ VERSION.dll ole32.dll - C:\ WINDOWS \ system32 \ ole32.dll SHELL32.dll - C:\ WINDOWS \ system32 \ SHELL32.dll COMDLG32.dll - C:\ WINDOWS \ system32 \ C OMDLG32.dll WINSPOOL.DRV - C:\ WINDOWS \ system32 \ WINSPOOL.DRV
当我尝试运行它时igot这个错误:
C:\final\dist>dev.exe
Traceback (most recent call last):
File "dev.py", line 9, in <module>
File "openpyxl\__init__.pyc", line 26, in <module>
File "openpyxl\compat\__init__.pyc", line 5, in <module>
File "openpyxl\compat\strings.pyc", line 9, in <module>
File "openpyxl\compat\numbers.pyc", line 28, in <module>
RuntimeError: Could not find the matplotlib data files
有人可以帮我解决一下吗?