Errors with Matplotlib when making an executable with Py2exe (Python)

我的未来我决定 提交于 2019-12-18 09:17:37

问题


I have a problem when trying to make an executable with a Python application.

For doing this, I'm using Py2exe with the 2.7 version of Python.

My application have 3 python scripts -> IHM_monotone_flux_GTC.py which is the one who launch a graphical interface

and then 2 others scripts: -> lectureDonnees.py -> main.py

In order to create an executable I made a setup.py file which is surely incomplete:

from distutils.core import setup import py2exe

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

Thanks for any help. (I'm working with Windows XP)

Cédric.


回答1:


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(),
)

You will need something like this in your setup.py for py2exe. hope it helps.



来源:https://stackoverflow.com/questions/18228774/errors-with-matplotlib-when-making-an-executable-with-py2exe-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!