Pyinstaller导入错误没有模块命名路径

时间:2016-02-07 13:34:52

标签: python import module

我正在尝试在python中构建一个程序,它使用了很多不同的模块。当我正常运行它(从cmd)一切正常,但是当我尝试创建一个可执行文件时不起作用。我已经尝试使用py2exe和pyinstaller,尝试谷歌搜索问题几个小时,但没有什么真正有效。当我从cmd运行exe时,我得到了这个。我试过手动导入必要的模块,但仍然没有工作。有什么想法吗?

Traceback (most recent call last):
File "<string>", line 35, in <module>

File "site-packages\pyttsx\__init__.py", line 39, in init

  File "site-packages\pyttsx\engine.py", line 45, in __init__

  File "site-packages\pyttsx\driver.py", line 66, in __init__

  File "site-packages\pyttsx\drivers\sapi5.py", line 37, in buildDriver

  File "site-packages\pyttsx\drivers\sapi5.py", line 46, in __init__

  File "site-packages\win32com\client\__init__.py", line 309, in WithEvents

  File "site-packages\win32com\client\gencache.py", line 524, in EnsureModule

  File "site-packages\win32com\client\gencache.py", line 291, in 
MakeModuleForTypelib

  File "site-packages\win32com\client\makepy.py", line 286, in 
GenerateFromTypeLibSpec

  File "site-packages\win32com\client\gencache.py", line 554, in 
AddModuleToCache

  File "site-packages\win32com\client\gencache.py", line 633, in _GetModule

  File "c:\users\giorgo~1\appdata\local\temp\tmppddzle\gen_py\C866CA3A-32F7-
11D2-9602-00C04F8EE628x0x5x4.py", line 10, in <module>

    import win32com.client.CLSIDToClass, pythoncom, pywintypes

  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", 
line 158, in load_module

    return self._importer.load_module(fullname, self._fullname)


  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", 
line 389, in load_module

    exec(bytecode, module.__dict__)

  File "site-packages\pythoncom.py", line 2, in <module>

  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", 
line 158, in load_module

    return self._importer.load_module(fullname, self._fullname)

  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", 
line 389, in load_module

    exec(bytecode, module.__dict__)

  File "site-packages\win32\lib\pywintypes.py", line 2, in <module>



  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", 
line 158, in load_module

    return self._importer.load_module(fullname, self._fullname)

  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", 
line 389, in load_module

    exec(bytecode, module.__dict__)

  File "os.py", line 120, in <module>

ImportError: No module named path

alltogether returned -1

1 个答案:

答案 0 :(得分:0)

我最近遇到了类似的问题。 setuptools 19.3中似乎存在一个错误。降级到setuptools 19.2为我修复了它。

要使用pip降级,只需输入:

pip install setuptools==19.2

我希望这适合你。