我试图将我的python脚本打包成可执行文件.我以为我会非常直接,因为我没有很多进口.首先是我的进口:
from __future__ import print_function from netCDF4 import Dataset import numpy as np import os from progressbar import Percentage,Bar,ETA,ProgressBar,RotatingMarker
我知道一个numpy
支持的事实我不确定__future__
或者os
我确信netCDF4
并且progressbar
不支持.我在Python 2.7.7 for Windows 7上使用pyinstaller 2.1版,这是我用来开始创建.exe的命令:
C:\Users\Patrick\Desktop\netcdf_grid_extraction>pyinstaller --onefile --hidden-i mport=netCDF4 --hidden-import=progressbar netcdf_grid_extraction.py
这是一个错误列表.似乎存在一个无法找到模块的主要问题pywintypes.dll
,以及与之相关的两个组件amd64_Microsoft
.这是我得到的4个错误的列表.我怎样才能解决这些问题?
1130 INFO: Searching for assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0. 21022.8_none ... 1134 WARNING: Assembly not found 1134 ERROR: Assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found 1210 INFO: Searching for assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0. 21022.8_none ... 1210 WARNING: Assembly not found 1210 ERROR: Assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found2
Traceback (most recent call last): File "3", line 11, in File "C:\Users\Patrick\Anaconda\lib\site-packages\pythoncom.py", line 2, in import pywintypes File "C:\Users\Patrick\Anaconda\lib\site-packages\win32\lib\pywintypes.py", li ne 124, in __import_pywin32_system_module__("pywintypes", globals()) File "C:\Users\Patrick\Anaconda\lib\site-packages\win32\lib\pywintypes.py", li ne 98, in __import_pywin32_system_module__ raise ImportError("No system module '%s' (%s)" % (modname, filename)) ImportError: No system module 'pywintypes' (pywintypes27.dll) 4155 INFO: Processing hook hook-pywintypes Traceback (most recent call last): File " ", line 11, in File "C:\Users\Patrick\Anaconda\lib\site-packages\pythoncom.py", line 2, in import pywintypes File "C:\Users\Patrick\Anaconda\lib\site-packages\win32\lib\pywintypes.py", li ne 124, in __import_pywin32_system_module__("pywintypes", globals()) File "C:\Users\Patrick\Anaconda\lib\site-packages\win32\lib\pywintypes.py", li ne 98, in __import_pywin32_system_module__ raise ImportError("No system module '%s' (%s)" % (modname, filename)) ImportError: No system module 'pywintypes' (pywintypes27.dll)
5840 INFO: Searching for assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0. 21022.8_none ... 5840 WARNING: Assembly not found 5840 ERROR: Assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found4
Traceback (most recent call last): File "C:\Users\Patrick\Anaconda\Scripts\pyinstaller-script.py", line 9, inload_entry_point('PyInstaller==2.1', 'console_scripts', 'pyinstaller')() File "C:\Users\Patrick\Anaconda\lib\site-packages\pyinstaller-2.1-py2.7.egg\Py Installer\main.py", line 88, in run run_build(opts, spec_file, pyi_config) File "C:\Users\Patrick\Anaconda\lib\site-packages\pyinstaller-2.1-py2.7.egg\Py Installer\main.py", line 46, in run_build PyInstaller.build.main(pyi_config, spec_file, **opts.__dict__) File "C:\Users\Patrick\Anaconda\lib\site-packages\pyinstaller-2.1-py2.7.egg\Py Installer\build.py", line 1924, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build' )) File "C:\Users\Patrick\Anaconda\lib\site-packages\pyinstaller-2.1-py2.7.egg\Py Installer\build.py", line 1873, in build execfile(spec) File "C:\Users\Patrick\Desktop\netcdf_grid_extraction\netcdf_grid_extraction.s pec", line 17, in console=True ) File "C:\Users\Patrick\Anaconda\lib\site-packages\pyinstaller-2.1-py2.7.egg\Py Installer\build.py", line 1170, in __init__ strip_binaries=self.strip, upx_binaries=self.upx, File "C:\Users\Patrick\Anaconda\lib\site-packages\pyinstaller-2.1-py2.7.egg\Py Installer\build.py", line 1008, in __init__ self.__postinit__() File "C:\Users\Patrick\Anaconda\lib\site-packages\pyinstaller-2.1-py2.7.egg\Py Installer\build.py", line 309, in __postinit__ self.assemble() File "C:\Users\Patrick\Anaconda\lib\site-packages\pyinstaller-2.1-py2.7.egg\Py Installer\build.py", line 1050, in assemble dist_nm=inm) File "C:\Users\Patrick\Anaconda\lib\site-packages\pyinstaller-2.1-py2.7.egg\Py Installer\build.py", line 842, in checkCache digest = cacheDigest(fnm) File "C:\Users\Patrick\Anaconda\lib\site-packages\pyinstaller-2.1-py2.7.egg\Py Installer\build.py", line 796, in cacheDigest data = open(fnm, "rb").read() IOError: [Errno 22] invalid mode ('rb') or filename: ''
以下是我得到的警告可能会或可能不会相关,并且都与无法找到相关 ctypes
890 WARNING: library python%s%s required via ctypes not found 2175 WARNING: library python%s%s required via ctypes not found
好消息是,似乎第三方模块正在考虑中,但我不确定它们是否与我所得到的错误有关:
4540 INFO: Hidden import 'netCDF4' has been found otherwise 4540 INFO: Hidden import 'progressbar' has been found otherwise 4540 INFO: Hidden import 'codecs' has been found otherwise 4545 INFO: Hidden import 'encodings' has been found otherwise
Lemayzeur.. 10
我刚才复制的DLL pywintypes27.dll
在C:\Python27\Lib\site-packages\pywin32_system32
.
我加入了win32/lib
.
没关系!
问题2的解决方案。下面链接中的解决方案为我解决了这个问题:)
在python 2.7上通过conda安装pywin32 build 219时,导入pythoncom失败并显示
ImportError: No system module 'pywintypes' (pywintypes27.dll)
问题是库pywintypes27.dll没有存储在
pathtovenv \ lib \ site-packages \ win32 \ lib \ pywintypes27.dll
但在
pathtovenv \ lib \ site-packages \ win32 \ pywintypes27.dll
在下面的elif部分中添加文件win32 \ lib \ pywintypes.py可以解决此问题
:::蟒蛇
if found is None: # Not in the Python directory? Maybe we were installed via # easy_install... if os.path.isfile(os.path.join(os.path.dirname(__file__), filename)): found = os.path.join(os.path.dirname(__file__), filename) elif os.path.isfile(os.path.join(os.path.dirname(__file__), "..", filename)): found = os.path.join(os.path.dirname(__file__), "..", filename)
简而言之,看起来pywintypes27.dll位于错误的文件夹中
http://sourceforge.net/p/pywin32/bugs/685/
我有同样的问题.dll,pywintypes27.dll位于C:\ Python27\Lib\site-packages\pywin32_system32中.我将此目录添加到我的PATH环境变量中,py2exe能够找到DLL.显然,设置路径不是正确的解决方案(你可以通过os.environ以编程方式进行),但是,对我有用.
我刚才复制的DLL pywintypes27.dll
在C:\Python27\Lib\site-packages\pywin32_system32
.
我加入了win32/lib
.
没关系!