CX_FREEEZE, INNO: could not find matplotlib data files

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
+5
source share
1 answer

Thanks, Thomas, yes, I first ran the frozen exe before making the installer. it was good. I found a solution: when importing a directory, inno copies all the files in the same directory as the exe file (Program Files (x86) directory). But if I define the same directory as the frozen exe, I have to add the mpl data to the Dest dir path. in iss INNO script:
line in script:

 \build\exe.win-amd64-2.7\mpl-data\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs 

I add the mpl-data directory to the path in the iss file in order to have the same relative path from exe to the mpl-data file in the installation directory and in the frozen directory:

 \build\exe.win-amd64-2.7\mpl-data\*"; DestDir: "{app}\mpl-data\"; Flags: ignoreversion recursesubdirs createallsubdirs 

I compile, install ... it works

+2
source

Source: https://habr.com/ru/post/1200242/


All Articles