我正在尝试将python projet编译为可执行文件cx_freeze。 python setup.py build
命令有效,我创建了我的.exe文件,但是当我想执行它时,我有一条原始异常错误消息:
Exception raised when calling format_exception
Exception: 'str' object has no attribute '__cause__'
Original exception: cannot import name _methods
在编译日志文件中,我发现了许多导入错误:
Missing modules:
? IPython.utils.generics imported from pandas.core.panel
? PIL imported from matplotlib.image
? PyQt4.QtCore imported from matplotlib.backends.qt4_compat
? Pyrex.Compiler.Main imported from numpy.distutils.command.build_src
? StringIO imported from six
? UserDict imported from pytz
? __config__ imported from numpy.distutils
? _curses imported from curses
? _frozen_importlib imported from pkg_resources
? _gestalt imported from platform
? _transforms imported from matplotlib.dates
? bottleneck imported from pandas.core.nanops
? cPickle imported from xlsxwriter.compat_collections
? cStringIO imported from pkg_resources
? compiler imported from numpy.lib.utils
? gobject imported from matplotlib.pyplot
? has_key imported from curses
? md5 imported from matplotlib.texmanager
? mpl_toolkits.natgrid imported from matplotlib.mlab
? multiprocessing._multiprocessing imported from multiprocessing.forking
? nose imported from numpy.testing.nosetester
? numarray imported from numpy.distutils.system_info
? numexpr imported from pandas.core.expressions
? numpy.core._dotblas imported from numpy.core.numeric
? numpy.core.exp imported from numpy.linalg.linalg
? numpy.core.integer imported from numpy.fft.helper
? numpy.core.signbit imported from numpy.testing.utils
? numpy.e imported from numpy.numarray.functions
? numpy_distutils imported from numpy.f2py.diagnose
? openpyxl.reader.excel imported from pandas.io.parsers
? pudb imported from pandas.util.testing
? pyemf imported from matplotlib.backends.backend_emf
? qt imported from matplotlib.pyplot
? scikits.statsmodels.api imported from pandas.stats.ols
? scipy imported from numpy.testing.nosetester
? sets imported from numpy.lib.function_base
? setuptools imported from numpy.distutils.core
? sip imported from matplotlib.backends.qt4_compat
? statsmodels.api imported from pandas.stats.ols
? sysconfig imported from pkg_resources
? tables imported from pandas.io.pytables
? thread imported from dateutil.rrule
? urlparse imported from pkg_resources
? wx imported from matplotlib.pyplot
? xlrd imported from pandas.io.parsers
? xlwt imported from pandas.io.parsers
我搜索了一些未导入的文件,但它们显然不在我的计算机上。所以我怀疑图书馆安装的错误,但似乎并不是这样。我安装了两次。还有什么呢?
我使用的是Python 3.1,cx_freeze 4.2.3,matplotlib 1.2.0,pandas 0.11.0和numpy 1.7.1。
这是我的setup.py
# -*- coding: utf-8 -*-
#!/usr/bin/env python
import sys, os
from cx_Freeze import setup, Executable
#############################################################################
path = sys.path + ["."]
includes = ['json', 'xml', 'PySide', 'xml.sax', 'xml.etree', 'xml.etree.ElementTree','xml.etree.cElementTree','xml.etree.ElementInclude','test',
'test.support','runpy','ctypes.util','logging.config','configparser','ctypes.wintypes','zipfile','sqlite3', 'io', 'subprocess',
'zlib','atexit','csv','pandas','matplotlib','numpy','xlsxwriter','re','itertools','os','sys']
include_files = []
excludes = []
packages = ['numpy.lib.format']
options = {"path": path,
"includes": includes,
"excludes": excludes,
"packages": packages,
"include_files": include_files,
"build_exe": "C:/temp/Test/",
"create_shared_zip" :False}
#############################################################################
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
cible_1 = Executable(
script = "D:/eDoc/src/Tool/main.py",
base = base,
compress = True,
appendScriptToExe = True,
appendScriptToLibrary = False,
copyDependentFiles = True,
targetName = 'Tool.exe',
targetDir = "C:/temp/Test/")
buildOptions = dict(create_shared_zip = False)
#############################################################################
setup(
name = 'Tool',
version = '1',
description = '' ,
author = '',
options = {'build_exe': options},
executables = [cible_1])
这是我在main.py中的导入
import sys
import os
import functools
import configparser
import time
import subprocess
import itertools
import csv
import numpy as np
import pandas as pd
from xlsxwriter.workbook import Workbook
#import matplotlib dependencies to merge Pyside and matplotlib plot
import matplotlib
matplotlib.use('wxAgg')
matplotlib.rcParams['backend']='qt4agg'
matplotlib.rcParams['backend.qt4']='PySide'
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import (FigureCanvasQTAgg as FigureCanvas, NavigationToolbar2QT as NavigationToolbar)
import matplotlib.pyplot as plt
import PySide
from PySide import QtCore,QtGui,QtUiTools
from PySide.QtUiTools import *
from PySide.QtCore import *
from PySide.QtGui import *
任何人都知道这个问题可能是什么原因?