我有一个使用BOKEH(0.12)生成图表的python应用程序,图表都是独立的(即BOKEHJS内联),因此浏览器无需访问网络找到CDN或进行任何外部连接。 当我从Eclipse运行它时一切正常,图表显示没问题。但是当我尝试使用py2exe打包时,会创建html文件,但是当我在浏览器中打开它时,不显示任何图表。这就是我的setup.py看起来像
from distutils.core import setup
import py2exe
import os
import psutil
import pkg_resources
import inspect
import matplotlib
import sys
import bokeh.core
import zipfile
sys.setrecursionlimit(5000)
includes=["sqlite3","PyQt4","decimal","bokeh.core","jinja2","matplotlib","mpl_toolkits","matplotlib.backends.backend_wx","bokeh"]
excludes=[]
packages=["pkg_resources"]
dll_excludes=['libgdk-win32-1.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll', 'tk84.dll', 'msvcp90.dll','msvcr71.dll', 'IPHLPAPI.DLL', 'NSI.dll', 'WINNSI.DLL', 'WTSAPI32.dll']
dir_name = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # script directory
parent_dir_name=os.path.abspath(os.path.join(dir_name,os.pardir))
iconfile_config_location = "my_icon.ico"
configuration_location = "my_configuration.ini"
database_location = "localDB"
datafiles = [('', [configuration_location,database_location])]
datafiles.extend(matplotlib.get_py2exe_datafiles())
current_dir = os.path.dirname(os.path.realpath(__file__))
dist_dir = os.path.join(current_dir, "release")
setup(
options={"py2exe": {"compressed": 2,
"optimize": 0,#string or int of optimization level (0, 1, or 2) 0 = do not optimize (generate .pyc) 1 = normal optimization (like python -O) 2 = extra optimization (like python -OO)
"includes": includes,
"excludes": excludes,
"packages": packages,
"dll_excludes": dll_excludes,
"bundle_files": 2,
"dist_dir": "release",
"xref": False,
"skip_archive": False,
"ascii": False,
"custom_boot_script": '',
}
},
windows=[{"script":"main.py","icon_resources": [(1, iconfile_config_location)],}],
data_files= datafiles
)
# Add boke/core/_templates files to the library.zip file
bokeh_path = sys.modules['bokeh.core'].__path__[0]
zipfile_path = os.path.join(dist_dir, "library.zip")
z = zipfile.ZipFile(zipfile_path, 'a')
for dirpath,dirs,files in os.walk(os.path.join(bokeh_path, '_templates')):
for f in files:
fn = os.path.join(dirpath, f)
z.write(fn, os.path.join(dirpath[dirpath.index('bokeh'):], f))
z.close()
任何人都可以指导我如何打包Bokeh,以便生成的可执行文件可以使用它。 (即一切都捆绑在一起)是否有可能?
我还注意到,当我将优化选项设置为2时,它不起作用,我收到错误
File "zipextimporter.pyo", line 82, in load_module
File "bokeh\plotting\__init__.pyo", line 2, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "bokeh\document.pyo", line 36, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "bokeh\model.pyo", line 12, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "bokeh\core\properties.pyo", line 73, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "bokeh\core\enums.pyo", line 25, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "bokeh\icons.pyo", line 78, in <module>
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'
任何想法