Pyinstaller和海运 [英] Pyinstaller and seaborn

查看:32
本文介绍了Pyinstaller和海运的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

这里是我在installTest.py中编写的要重现的最简单的代码段

import seaborn
print 'It works now!'

然后我在控制台中键入pyinstaller .installTest

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

您对如何解决此问题有什么想法吗?

推荐答案

我找到问题了。

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

# -*- 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')

这篇关于Pyinstaller和海运的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆