Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
550 views
in Technique[技术] by (71.8m points)

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

I am trying to package my python script into an executable. I thought I would be pretty straight forward as I don't have very many imports. First off here are my imports:

from __future__ import print_function 
from netCDF4 import Dataset
import numpy as np
import os
from progressbar import Percentage,Bar,ETA,ProgressBar,RotatingMarker  

I know for a fact that numpy is supported I'm not sure about __future__ or os and I know for sure that netCDF4 and progressbar are not supported. I am using pyinstaller version 2.1 on Python 2.7.7 for Windows 7, and here is the command I use to start creating .exe:

C:UsersPatrickDesktop
etcdf_grid_extraction>pyinstaller --onefile --hidden-i
mport=netCDF4 --hidden-import=progressbar netcdf_grid_extraction.py

Here is a list of errors. There seems to be one major problem with not being able to find the module pywintypes.dll, as well as two assemblies related to amd64_Microsoft. Here is a list of the 4 errors I get. How can I go about solving these?

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:UsersPatrickAnacondalibsite-packagespythoncom.py", line 2, in <m
odule>
    import pywintypes
  File "C:UsersPatrickAnacondalibsite-packageswin32libpywintypes.py", li
ne 124, in <module>
    __import_pywin32_system_module__("pywintypes", globals())
  File "C:UsersPatrickAnacondalibsite-packageswin32libpywintypes.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:UsersPatrickAnacondalibsite-packagespythoncom.py", line 2, in <m
odule>
    import pywintypes
  File "C:UsersPatrickAnacondalibsite-packageswin32libpywintypes.py", li
ne 124, in <module>
    __import_pywin32_system_module__("pywintypes", globals())
  File "C:UsersPatrickAnacondalibsite-packageswin32libpywintypes.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:UsersPatrickAnacondaScriptspyinstaller-script.py", line 9, in <mo
dule>
    load_entry_point('PyInstaller==2.1', 'console_scripts', 'pyinstaller')()
  File "C:UsersPatrickAnacondalibsite-packagespyinstaller-2.1-py2.7.eggPy
Installermain.py", line 88, in run
    run_build(opts, spec_file, pyi_config)
  File "C:UsersPatrickAnacondalibsite-packagespyinstaller-2.1-py2.7.eggPy
Installermain.py", line 46, in run_build
    PyInstaller.build.main(pyi_config, spec_file, **opts.__dict__)
  File "C:UsersPatrickAnacondalibsite-packagespyinstaller-2.1-py2.7.eggPy
Installeruild.py", line 1924, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'
))
  File "C:UsersPatrickAnacondalibsite-packagespyinstaller-2.1-py2.7.eggPy
Installeruild.py", line 1873, in build
    execfile(spec)
  File "C:UsersPatrickDesktop
etcdf_grid_extraction
etcdf_grid_extraction.s
pec", line 17, in <module>
    console=True )
  File "C:UsersPatrickAnacondalibsite-packagespyinstaller-2.1-py2.7.eggPy
Installeruild.py", line 1170, in __init__
    strip_binaries=self.strip, upx_binaries=self.upx,
  File "C:UsersPatrickAnacondalibsite-packagespyinstaller-2.1-py2.7.eggPy
Installeruild.py", line 1008, in __init__
    self.__postinit__()
  File "C:UsersPatrickAnacondalibsite-packagespyinstaller-2.1-py2.7.eggPy
Installeruild.py", line 309, in __postinit__
    self.assemble()
  File "C:UsersPatrickAnacondalibsite-packagespyinstaller-2.1-py2.7.eggPy
Installeruild.py", line 1050, in assemble
    dist_nm=inm)
  File "C:UsersPatrickAnacondalibsite-packagespyinstaller-2.1-py2.7.eggPy
Installeruild.py", line 842, in checkCache
    digest = cacheDigest(fnm)
  File "C:UsersPatrickAnacondalibsite-packagespyinstaller-2.1-py2.7.eggPy
Installeruild.py", line 796, in cacheDigest
    data = open(fnm, "rb").read()
IOError: [Errno 22] invalid mode ('rb') or filename: ''

And here are the warnings I get that may or may not be relevent and are both related to not being able to find ctypes

890 WARNING: library python%s%s required via ctypes not found
2175 WARNING: library python%s%s required via ctypes not found

The good news is that its seems the third party modules are being accounted for however I am not sure if they are associated with the errors that I am gettting:

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I just copied the DLL pywintypes27.dll in C:Python27Libsite-packagespywin32_system32.
I added it in win32/lib.

It's OK!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...