pyinstaller,导入错误:没有名为pywintypes的模块

时间:2017-05-06 12:15:39

标签: python python-2.7 command-prompt pyinstaller

我想使用pyinstaller从py脚本创建exe。我在cmd" pyinstaller --onefile --windowed filename.py"中编写了以下命令,但cmd显示错误。我该如何解决这个问题?

Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\pyinstaller.exe\__main__.py", line 5, in <module>
  File "c:\python27\lib\site-packages\PyInstaller\__main__.py", line 21, in <module>
    import PyInstaller.building.build_main
  File "c:\python27\lib\site-packages\PyInstaller\building\build_main.py", line 32, in <module>
    from ..depend import bindepend
  File "c:\python27\lib\site-packages\PyInstaller\depend\bindepend.py", line 38, in <module>
    from ..utils.win32.winmanifest import RT_MANIFEST
  File "c:\python27\lib\site-packages\PyInstaller\utils\win32\winmanifest.py", line 97, in <module>
    from PyInstaller.utils.win32 import winresource
  File "c:\python27\lib\site-packages\PyInstaller\utils\win32\winresource.py", line 20, in <module>
    import pywintypes
ImportError: No module named pywintypes

编辑:我试过&#34; pip install pypiwin32,但仍然有相同的ImportError

2 个答案:

答案 0 :(得分:1)

如果您使用的是Windows,则应尝试使用virtualenv。我推荐Anaconda。您将能够轻松安装大多数python包。

安装Anaconda后,只需运行conda install -c conda-forge pyinstaller=3.2.1 即可。

希望这有帮助。

答案 1 :(得分:0)

在某些情况下,您必须手动提及需要通过关键字打包的模块&#34; - hidden-import

所以在你的情况下:     pyinstaller --onefile --hidden-import = pywintypes --windowed filename.py