我正在尝试部署应用程序,但它在导入海运时崩溃
这是我的配置: Python 2.7,pyinstaller 3.3.1,seaborn 0.8.1。
下面是我用installTest.py编写的最简单的重现代码
import seaborn
print 'It works now!'然后在控制台中输入pyinstaller .\installTest
我得到一个很长的错误代码,以找不到messagesstream模块终止。
你对如何解决这个问题有什么想法吗?
发布于 2018-05-02 21:52:58
我找到我的问题了。
首先,下面是这个小示例的工作原理:我修改了我的.spec文件,使其包含一些隐藏的导入以及一些pandas和seaborn内容
# -*- mode: python -*-
block_cipher = None
def get_seaborn_path():
import seaborn
seaborn_path = seaborn.__path__[0]
return seaborn_path
def get_pandas_path():
import pandas
pandas_path = pandas.__path__[0]
return pandas_path
a = Analysis(['installTest.py'],
pathex=['C:\\Users\\Admin\\PycharmProjects\\InstalTest'],
binaries=[],
datas=[],
hiddenimports=['scipy._lib.messagestream', 'pandas._libs.tslibs.timedeltas '],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
dict_tree = Tree(get_seaborn_path(), prefix='seaborn', excludes=["*.pyc"])
dict_tree2 = Tree(get_pandas_path(), prefix='pandas', excludes=["*.pyc"])
a.datas += dict_tree
a.datas += dict_tree2
a.binaries = filter(lambda x: 'seaborn' not in x[0], a.binaries)
a.binaries += filter(lambda x: 'pandas' not in x[0], a.binaries)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='installTest',
debug=True,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='installTest')https://stackoverflow.com/questions/50135676
复制相似问题