I made an executable from python and cx_freeze scripts. Freezing looks fine. But I have problems when I use INNO to create the installation file. I can create the installation and successfully deploy the application. But while I run it from the "Program Files (x86)" directory, I have a runtime error: could not find matplotlib data files
C:\Program Files (x86)\GLADDataExtraction>main Traceback (most recent call last): File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module> exec(code, m.__dict__) File "main.py", line 8, in <module> File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 947, in <module> rcParams = rc_params() File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 865, in rc_params return rc_params_from_file(fname, fail_on_error) File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 930, in rc_params_from_file ret['datapath'] = get_data_path() File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 312, in wrapper ret = func(*args, **kwargs) File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 655, in _get_data_path_cached defaultParams['datapath'][0] = _get_data_path() File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 651, in _get_data_path raise RuntimeError('Could not find the matplotlib data files') RuntimeError: Could not find the matplotlib data files
I searched the Internet quite extensively, without success. There are many topics related to py2exe, but not for cx_freeze. I examined the setup.py cx_freeze file shown below:
#!/usr/bin/python # -*- coding: utf-8 -*- # Python 2.7 # 02/2011 import sys, os from cx_Freeze import setup, Executable import matplotlib ############################################################################# # préparation des options # chemins de recherche des modules path='D:\\IceSat\\tests\\test_executable\\test_GLASDataExtraction' if os.path.exists(path): print "exist" if path in sys.path: print "OK" else: print "insert" sys.path.append(path) path = sys.path + ["package_interface", "package_traitement"] ##build_exe_options = { 'packages': ['scipy'], ## "include_files": [('C:\\Python27\\Lib\\site-packages\\scipy\\special\\_ufuncs.pyd','_ufuncs.pyd')]} # options d'inclusion/exclusion des modules ##includes = ["sip", "matplotlib"] includes = ["sip"] ##excludes = ["tk","tcl"] excludes = [] ##packages = ["scipy", "scipy.signal", "scipy.special", "matplotlib", "matplotlib.mpl-data"] ##packages = ["scipy", "scipy.signal", "scipy.special", "matplotlib", "matplotlib.backends"] ##packages = ["scipy", "scipy.signal", "scipy.special", "matplotlib"] packages = ["scipy", "scipy.signal", "scipy.special"] ##packages = ["scipy", "scipy.signal", "scipy.special", "matplotlib", "matplotlib.backends", "matplotlib.mpl-data"] ### construction du dictionnaire des options options = {"path": path, "includes": includes, "excludes": excludes, "packages": packages, ## "include_files": includefiles, "include_files":[(matplotlib.get_data_path(),"mpl-data")] ## "include_files":[(matplotlib.get_data_path(),"HDE")] #### "include_files":[matplotlib.get_data_path(),"C:\\Python27\\Lib\site-packages\\matplotlib\\mpl-data"] ## "bin_path_includes": binpathincludes } # création du setup setup( name = "GLASDataExtraction", version = "1", description = "Extraction et analyse de data GLAS", author = "Henri", options = {"build_exe": options}, ## executables = [cible_1] executables=[Executable("main.py")] )
There are many comments because I tried to simplify the setup.py file as much as possible without affecting the assembly directory. After launch
python setup.py build
in the DOS window, the directory 'build / exe ...' is created. Inside there are:
- library.zip file with many packages (matplotlib inside, but without mpl data, which does not look like a package, since there is no init .py file).
- many .pyd files
- 4 directory: imageformats, mpl-data, tcl, tk. mpl-data is with its contents.
Then my installation file is created using the INNO application in the "Program Files (x86)" directory. I start the installation with this installation file. This is normal. My program directory is created with several directories and files. These include files from "C: \ Python27 \ Lib \ site-packages \ matplotlib \ mpl-data". But when I run the .exe file, I have the error "RuntimeError: could not find matplotlib data files".
My configuration:
- WINDOWS 7 64 bit
- python 2.7 64 bit
- cx_freeze 4.3.3
- inno 5.5.5
- PyQt4