首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pyinstaller和seaborn

Pyinstaller和seaborn
EN

Stack Overflow用户
提问于 2018-05-02 21:18:40
回答 1查看 612关注 0票数 0

我正在尝试部署应用程序,但它在导入海运时崩溃

这是我的配置: Python 2.7,pyinstaller 3.3.1,seaborn 0.8.1。

下面是我用installTest.py编写的最简单的重现代码

代码语言:javascript
复制
import seaborn
print 'It works now!'

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

我得到一个很长的错误代码,以找不到messagesstream模块终止。

你对如何解决这个问题有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2018-05-02 21:52:58

我找到我的问题了。

首先,下面是这个小示例的工作原理:我修改了我的.spec文件,使其包含一些隐藏的导入以及一些pandas和seaborn内容

代码语言:javascript
复制
# -*- 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')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50135676

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档