Pyinstaller和seaborn

2024-10-02 02:24:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图部署一个应用程序,当导入seaborn时它崩溃了

这是我的配置:python2.7,pyinstaller 3.3.1,seaborn 0.8.1。在

这里是我所写的最简单的代码片段安装测试.py在

import seaborn
print 'It works now!'

然后在控制台中输入pyinstaller .\installTest

我得到一个长错误代码,以找不到messagesstream模块结尾。在

你有什么办法解决这个问题吗?在


Tags: 模块代码pyimport应用程序部署itseaborn
1条回答
网友
1楼 · 发布于 2024-10-02 02:24:11

我发现了我的问题。在

首先是这个小例子的工作原理:我修改了我的.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')

相关问题 更多 >

    热门问题