我一直在搜索这个论坛和许多其他论坛,似乎找不到创建可执行文件的好方法。我尝试了几种不同的方法(py2exe、pyinstaller 和 cx_freeze),似乎都给了我某种错误。
当我尝试 pyinstaller 时,我收到“未安装 _imaging C 模块”的错误。我搜索的所有内容都表明它与 PIL 有关,但我的代码没有使用 PIL。
当我尝试 py2exe 时,我不断收到以下错误:
File "Scout_Tool.py", line 18, in <module>
File "matplotlib\pyplot.pyc", line 95, in <module>
File "matplotlib\backends\__init__.pyc", line 25, in pylab_setup
ImportError: No module named backend_qt4agg
我不知道该怎么办。我的代码包含以下导入:
import os
import csv
import wx
import time
import math
from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.pyplot import figure,show
from mpl_toolkits.basemap import Basemap
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
from numpy.random import rand
from datetime import datetime
import wx.calendar as cal
import numpy as npy
from pylab import *
import numpy as np
import matplotlib
import adodbapi
import sqlparse
import pylab
import annote_new
import cPickle as pickle
有人对如何使用 py2exe 构建可执行文件有任何建议吗?我尝试过的...
from distutils.core import setup
import py2exe
import matplotlib
setup(
windows=[{'script': r'Scout_Tool.py'}],
data_files=matplotlib.get_py2exe_datafiles(),
options={
r'py2exe': {
r'includes': r'ElementConfig',
r'includes': r'ColorConv',
r'includes': r'Tkinter',
r'includes': r're',
r'includes': r'math',
r'includes': r'sys',
r'includes': r'matplotlib',
r'includes': r'mpl_toolkits',
r'includes': r'matplotlib.backends.backend_wx',
r'dll_excludes': [r'MSVCP90.dll'],
}
},
)
谢谢你的帮助!