cx_Freeze ImportError:没有名为' pythoncom'

时间:2016-11-24 09:11:28

标签: windows python-3.5 cx-freeze pywin32 pythoncom

问题

尝试运行使用cx_Freeze生成的.exe时出现以下错误:

ImportError:没有名为' pythoncom'

的模块

我该如何解决这个问题?

cx_Freeze: Python error in main script

其他信息

设定:

  • Windows 7 Enterprise 64位
  • WinPython-64bit-3.5.2.3Qt5(Python 3.5.2 64位)
  • cx_Freeze 5.0

setup.py:

import os
import sys
from cx_Freeze import setup, Executable


os.environ['TCL_LIBRARY'] = r"C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\tcl\tcl8.6" 
os.environ['TK_LIBRARY'] = r"C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\tcl\tk8.6" 


base = 'Console'
if sys.platform == 'win32':
    base = 'Win32GUI'

options = {
    'build_exe': {
        'excludes': ['gtk', 'PyQt4', 'Tkinter'],
        'includes': ['pythoncom']
    }
}


executables = [
    Executable('GUI.py', base=base)
]


setup(name='GUI',
      version='0.1',
      description='GUI test',
      executables=executables,
      options=options
      )

GUI.py *

中的导入

*部分内容

from bs4 import BeautifulSoup
import requests
import win32com.client, pythoncom

from PyQt5 import QtCore, QtGui, QtWidgets

from matplotlib import use as MPLuse
MPLuse("Qt5Agg",force=True)

from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure

import seaborn as sns

使用' pythoncom'构建输出行或者' pywin':

m pythoncom                 C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\pythoncom35.dll
...
copying C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\pythoncom35.dll -> build\exe.win-amd64-3.5\pythoncom35.dll

..
P pywin                     C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\Pythonwin\pywin\__init__.py
P pywin.dialogs             C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\Pythonwin\pywin\dialogs\__init__.py
m pywin.dialogs.list        C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\Pythonwin\pywin\dialogs\list.py
m pywin.dialogs.status      C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\Pythonwin\pywin\dialogs\status.py
P pywin.mfc                 C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\Pythonwin\pywin\mfc\__init__.py
m pywin.mfc.dialog          C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\Pythonwin\pywin\mfc\dialog.py
m pywin.mfc.object          C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\Pythonwin\pywin\mfc\object.py
m pywin.mfc.thread          C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\Pythonwin\pywin\mfc\thread.py
m pywin.mfc.window          C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\Pythonwin\pywin\mfc\window.py
m pywintypes                C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\pywintypes35.dll

..

copying C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\pywintypes35.dll -> build\exe.win-amd64-3.5\pywintypes35.dll

构建期间的错误:

我还尝试了什么?

  1. 在没有'includes': ['pythoncom']的情况下构建。结果是一样的。
  2. 使用'packages': ['pythoncom']构建。结果是一样的。
  3. 使用'includes': ['pywin32']构建。在构建期间将获得ImportError: No module named 'pywin32'
  4. 使用'packages': ['pywin32']构建。在构建期间将获得ImportError: No module named 'pywin32'

0 个答案:

没有答案