gpt4 book ai didi

matplotlib - CX_FREEEZE,INNO : could not find the matplotlib data files

转载 作者:行者123 更新时间:2023-12-04 21:15:16 31 4
gpt4 key购买 nike

我从 python 脚本和 cx_freeze 制作了一个可执行文件。冷冻看起来没问题。但是当我使用 INNO 创建安装文件时我遇到了问题。我可以创 build 置并成功部署应用程序。但是当我从“Program Files (x86)”目录启动它时,我有一个运行时错误:找不到 matplotlib 数据文件

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

我在互联网上广泛地寻找解释,但没有成功。有许多与 py2exe 相关的主题,但没有与 cx_freeze 相关的主题。
我调查了我的 cx_freeze setup.py 文件,如下所示:
#!/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")]
)

有很多评论是因为我试图在不影响构建目录的情况下尽可能简化 setup.py 文件。
启动后
python setup.py build

在 DOS 窗口中,创建目录“build/exe...”。
里面有:
  • library.zip 文件包含许多包(matplotlib 在里面,但没有 mpl-data,它看起来不像一个包,因为没有 init .py 文件)。
  • 许多 .pyd 文件
  • 4 目录:imageformats、mpl-data、tcl、tk。 mpl-data 在那里
    它的内容。

  • 然后,我的安装文件是在“Program Files (x86)”目录中用 INNO 应用程序创建的。我用这个安装文件启动安装。看起来没问题。我的程序目录是用很少的目录和文件创建的。来自“C:\Python27\Lib\site-packages\matplotlib\mpl-data”的文件就在这些文件中。但是当我启动 .exe 文件时,出现错误“RuntimeError:找不到 matplotlib 数据文件”。

    我的配置是:
  • WINDOWS 7 64 位
  • python 2.7 64 位
  • cx_freeze 4.3.3
  • inno 5.5.5
  • pyqt4
  • 最佳答案

    谢谢托马斯,是的,我在安装程序之前首先运行了卡住的 exe。还可以。
    我找到了一个解决方案:在导入目录时,inno 将所有文件复制到与 exe 文件(Program Files (x86) 目录)相同的目录中。但是如果我定义了与frozen exe相同的目录,我必须在路径Dest dir中添加mpl-data。在 iss INNO 脚本中:
    脚本中的行是:

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

    我在 iss 文件的路径中添加了 mpl-data 目录,以便在安装目录和卡住目录中从 exe 到 mpl-data 文件具有相同的相对路径:
    \build\exe.win-amd64-2.7\mpl-data\*"; DestDir: "{app}\mpl-data\"; Flags: ignoreversion recursesubdirs createallsubdirs

    我编译,安装...它的工作原理

    关于matplotlib - CX_FREEEZE,INNO : could not find the matplotlib data files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25291116/

    31 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com