hen*_*i d 5 inno-setup matplotlib cx-freeze
我从python脚本和cx_freeze创建了一个可执行文件.冷冻看起来还不错.但是,当我使用INNO创建设置文件时,我遇到了问题.我可以创建设置并成功部署应用程序.但是当我从"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
Run Code Online (Sandbox Code Playgroud)
我非常广泛地在互联网上寻找解释而没有成功.有很多主题链接到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")]
)
Run Code Online (Sandbox Code Playgroud)
有很多评论,因为我试图尽可能简化setup.py文件,而不会影响构建目录.发射后
python setup.py build
Run Code Online (Sandbox Code Playgroud)
在DOS窗口中,创建目录'build/exe ...'.里面有:
然后,使用"Program Files(x86)"目录中的INNO应用程序创建我的安装文件.我使用此安装文件启动安装.看起来不错.我的程序目录是用很少的目录和文件创建的.来自"C:\ Python27\Lib\site-packages\matplotlib\mpl-data"的文件属于这些文件.但是当我启动.exe文件时,我遇到错误"RuntimeError:找不到matplotlib数据文件".
我的配置是:
谢谢托马斯,是的,我在安装程序之前首先运行冻结的 exe。还可以。我找到了一个解决方案:在导入目录时,inno将所有文件复制到与exe文件相同的目录(Program Files(x86)目录)中。但是,如果我定义与 freeze exe 相同的目录,则必须在路径 Dest dir 中添加 mpl-data。在 iss INNO 脚本中:
脚本中的行是:
\build\exe.win-amd64-2.7\mpl-data\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Run Code Online (Sandbox Code Playgroud)
我在 iss 文件的路径中添加 mpl-data 目录,以便在安装目录和冻结目录中从 exe 到 mpl-data 文件具有相同的相对路径:
\build\exe.win-amd64-2.7\mpl-data\*"; DestDir: "{app}\mpl-data\"; Flags: ignoreversion recursesubdirs createallsubdirs
Run Code Online (Sandbox Code Playgroud)
我编译,安装......它有效
| 归档时间: |
|
| 查看次数: |
718 次 |
| 最近记录: |