python - Pyinstaller导入报错没有模块命名路径

标签 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

最佳答案

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

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

pip install setuptools==19.2

我希望这对你有用。

关于python - Pyinstaller导入报错没有模块命名路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35254139/

相关文章:

.net - 在 VB.NET 中使用模块是否被认为是不好的做法?

python - 拆分标题值为 : pythonic way 的列表

python - 访问函数内的全局变量

python - 我可以在 python 中提供 gcloud 命令吗

xml - 如何将大 XML 文件 (~10GB) 导入 PostgreSQL

python - 导入并读取Python文件夹中的所有文件

python - 如何在文件读取期间从每一行中去除换行符?

java - 导入和静态导入的区别?

javascript - 在我的例子中如何访问 JavaScript 模块模式?

c# - 无法使用 IronPython 导入用 C# 编写的模块