python - Pyinstaller - ImportError : No system module 'pywintypes' (pywintypes27. dll)

标签 python exe pyinstaller

我正在尝试将我的 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 我确定 netCDF4progressbar 不受支持。我在 Windows 7 的 Python 2.7.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 个错误的列表。我该如何解决这些问题?

1

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 found

2

Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "C:\Users\Patrick\Anaconda\lib\site-packages\pythoncom.py", line 2, in <m
odule>
    import pywintypes
  File "C:\Users\Patrick\Anaconda\lib\site-packages\win32\lib\pywintypes.py", li
ne 124, in <module>
    __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 "<string>", line 11, in <module>
  File "C:\Users\Patrick\Anaconda\lib\site-packages\pythoncom.py", line 2, in <m
odule>
    import pywintypes
  File "C:\Users\Patrick\Anaconda\lib\site-packages\win32\lib\pywintypes.py", li
ne 124, in <module>
    __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)

3

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 found

4

Traceback (most recent call last):
  File "C:\Users\Patrick\Anaconda\Scripts\pyinstaller-script.py", line 9, in <mo
dule>
    load_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 <module>
    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

最佳答案

我刚刚复制了 C:\Python27\Lib\site-packages\pywin32_system32 中的 DLL pywintypes27.dll
我在 win32/lib 中添加了它。

没关系!

关于python - Pyinstaller - ImportError : No system module 'pywintypes' (pywintypes27. dll),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25254285/

相关文章:

python - df.reindex() 和 df.loc[] 的区别

python - 我安装了 32 位 python 和 32 位 WMI 模块,但 wmi 返回错误

python - 在数据框中标记用户的出席情况

在C程序中调用.exe文件

c# - 如何以编程方式创建和构建 .exe?

python - 使用 PyInstaller 转换为 .app 的 Tkinter 程序立即关闭

python - 使用 PyInstaller 时出错

python - 是否有可能知道哪些 SciPy/NumPy 函数在多核上运行?

jar - 能够在没有JDK的情况下在不同的计算机上运行java应用程序

python - py安装程序 "unable to find a txt file when adding a binary"