使用自动py-to-exe将.py转换为.exe,显示错误

时间:2019-07-31 05:30:16

标签: python pyinstaller mayavi mayavi.mlab

我想将.py转换为.exe。为此,我知道auto-py-to-exe很简单,并且适用于Python> = 2.7(包括3.7)。当我尝试转换一个简单的应用程序时,它运行顺利(auto-py-exe在运行)。但是,当我尝试转换原始的python脚本时,会抛出错误:

An error occurred, traceback follows:
Traceback (most recent call last):
  File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
    yield
  File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\core\cffi\_dll.py", line 26, in _LoadLibraryEx
    function_name='LoadLibraryEx')
  File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\core\cffi\_util.py", line 81, in __call__
    self._raise_error(function_name)
  File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\core\cffi\_util.py", line 92, in _raise_error
    raise exception
OSError: [WinError 2] The system cannot find the file specified

这是我第一次将代码转换为.exe,所以我不知道现在该怎么做(除了在网络上搜索)。我什至不知道是什么导致此错误。我对mayavi有疑问,但不确定。任何帮助将受到高度欢迎。

程序:python 3.7

GUI:PyQt5

库包括:mayavi,opencv,matplotlib,PIL,pylab,scipy等

要转换的命令:pyinstaller -y“ path_to_script.py”

修改: 我确定它是由于mayavi所致,因为附加的最简单的代码未转换为.exe(抱歉,冗长的帖子!) 这是由于mayavi引起的,但是我仍然想要解决这个问题,在此先感谢您的任何建议。

代码:

import numpy as np
from mayavi.mlab import contour3d
from mayavi import mlab

x, y, z = np.ogrid[-3:3:60j, -3:3:60j, -3:3:60j]

H1   =   0.45+x**2+y**2-z**2
obj1 = contour3d(H1, contours=[0], transparent=False)
mlab.show()

要转换的命令:pyinstaller -y“ path_to_script.py”

错误:

An error occurred, traceback follows:
Traceback (most recent call last):
  File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
    yield
  File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\core\cffi\_dll.py", line 26, in _LoadLibraryEx
    function_name='LoadLibraryEx')
  File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\core\cffi\_util.py", line 81, in __call__
    self._raise_error(function_name)
  File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\core\cffi\_util.py", line 92, in _raise_error
    raise exception
OSError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\lab_pc\anaconda3\lib\site-packages\auto_py_to_exe\__main__.py", line 269, in convert
    pyi.run() # Execute PyInstaller
  File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build
    exec(code, spec_namespace)
  File "C:\Users\lab_pc\AppData\Local\Temp\tmp_0mronij\stackoverflow_ask_py2exe.spec", line 17, in <module>
    noarchive=False)
  File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 243, in __init__
    self.__postinit__()
  File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()
  File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 567, in assemble
    redirects=self.binding_redirects))
  File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 231, in Dependencies
    for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects):
  File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 407, in getAssemblyFiles
    for assembly in getAssemblies(pth):
  File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 358, in getAssemblies
    res = GetManifestResources(pth)
  File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1005, in GetManifestResources
    return winresource.GetResources(filename, [RT_MANIFEST], names, languages)
  File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\utils\win32\winresource.py", line 168, in GetResources
    hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
  File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "c:\users\lab_pc\anaconda3\lib\contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
    raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (2, 'LoadLibraryEx', 'The system cannot find the file specified')

Project output will not be moved to output folder
Complete.

我应该使用其他工具进行转换吗? (请针对我的问题提出建议)。 谢谢

0 个答案:

没有答案
相关问题