使用Py2exe制作可执行文件时,Matplotlib错误(Python) [英] Errors with Matplotlib when making an executable with Py2exe (Python)
问题描述
尝试用Python应用程序制作可执行文件时遇到问题.
I have a problem when trying to make an executable with a Python application.
为此,我将Py2exe与2.7版本的Python配合使用.
For doing this, I'm using Py2exe with the 2.7 version of Python.
我的应用程序具有3个python脚本 -> IHM_monotone_flux_GTC.py,它是启动图形界面的人
My application have 3 python scripts -> IHM_monotone_flux_GTC.py which is the one who launch a graphical interface
,然后是另外2个脚本: ->讲堂Donnees.py -> main.py
and then 2 others scripts: -> lectureDonnees.py -> main.py
为了创建可执行文件,我制作了一个setup.py文件,该文件肯定不完整:
In order to create an executable I made a setup.py file which is surely incomplete:
从distutils.core导入设置 导入py2exe
from distutils.core import setup import py2exe
设置(windows = ['IHM_monotone_flux_gtc.py'])
setup(windows=['IHM_monotone_flux_gtc.py'])
不幸的是,它不起作用,并且我收到了此错误消息:
Unfortunetaly, it doesn't work and I got this error message:
Traceback (most recent call last):
File "IHM_monotone_flux_gtc.py", line 16, in <module>
File "main.pyc", line 22, in <module>
File "matplotlib\__init__.pyc", line 838, in <module>
File "matplotlib\__init__.pyc", line 749, in rc_params
File "matplotlib\__init__.pyc", line 664, in matplotlib_fname
File "matplotlib\__init__.pyc", line 292, in wrapper
File "matplotlib\__init__.pyc", line 585, in _get_data_path_cached
File "matplotlib\__init__.pyc", line 581, in _get_data_path
RuntimeError: Could not find the matplotlib data files
感谢您的帮助. (我正在使用Windows XP)
Thanks for any help. (I'm working with Windows XP)
塞德里克.
推荐答案
您还将需要复制mpl-data文件夹.检查此官方Wiki网站 http://www.py2exe.org/index.cgi/MatPlotLib
You will need to copy the mpl-data folder too. Check this official wiki site http://www.py2exe.org/index.cgi/MatPlotLib
import matplotlib
...
setup(
...
data_files=matplotlib.get_py2exe_datafiles(),
)
对于py2exe,您将在setup.py中需要类似的内容. 希望对您有帮助.
You will need something like this in your setup.py for py2exe. hope it helps.
这篇关于使用Py2exe制作可执行文件时,Matplotlib错误(Python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!