首页 > 解决方案 > 当从 cmd 运行但在 Anaconda Prompt 中运行时,Pyinstaller EXE 在 Seaborn relplot 崩溃

问题描述

我用 Pyinstaller 创建了一个可执行文件。从 cmd 运行可执行文件,它在开始创建 relplot 时崩溃。为了创建 exe,我使用了这个命令:pyinstaller test.py --onefile. 这是test.py:

#!/usr/bin/env python
import seaborn as sns

print('###################relplot##########################')
tips = sns.load_dataset("tips")
g = sns.relplot(data=tips, x="total_bill", y="tip", hue="day")
g.fig.savefig('.\\test.png')
print('success')

康达资料:

shell level : 2
conda version : 4.9.2
conda-build version : 3.20.5
python version : 3.8.5.final.0
virtual packages : __cuda=11.1=0
                   __win=0=0
                   __archspec=1=x86_64
platform : win-64
user-agent : conda/4.10.1 requests/2.25.1 CPython/3.8.8 Windows/10 Windows/10.0.19041
administrator : False
netrc file : None
offline mode : False

构建 .exe 时的 Pyinstaller 警告文件。

Pyinstaller 在运行时调试消息,--debug=imports它崩溃的底部查看。

我尝试过更新环境和库,编写疯狂的 .spec 文件。似乎没有任何效果。我知道这篇文章。但是解决方案不起作用,这个问题没有得到太多关注,而且不完整,我不能对此发表评论,对我来说,它似乎与我的问题略有不同。

更新: exe 文件在 Anaconda Prompt 中运行没有问题,但在 cmd 中崩溃。我尝试了这里提供的解决方案,但没有奏效。

Conda 虚拟环境 Python 3.7.10:

name: test_env
channels:
  - defaults
dependencies:
  - altgraph=0.17=pyhd3eb1b0_0
  - blas=1.0=mkl
  - ca-certificates=2021.1.19=haa95532_1
  - certifi=2020.12.5=py37haa95532_0
  - cycler=0.10.0=py37_0
  - freetype=2.10.4=hd328e21_0
  - future=0.18.2=py37_1
  - icc_rt=2019.0.0=h0cc432a_1
  - icu=58.2=ha925a31_3
  - intel-openmp=2020.2=254
  - jpeg=9b=hb83a4c4_2
  - kiwisolver=1.3.1=py37hd77b12b_0
  - libpng=1.6.37=h2a8f88b_0
  - macholib=1.14=pyhd3eb1b0_1
  - matplotlib=3.2.2=0
  - matplotlib-base=3.2.2=py37h64f37c6_0
  - mkl=2020.2=256
  - mkl-service=2.3.0=py37h196d8e1_0
  - mkl_fft=1.3.0=py37h46781fe_0
  - mkl_random=1.1.1=py37h47e9c7a_0
  - numpy=1.19.2=py37hadc3359_0
  - numpy-base=1.19.2=py37ha3acd2a_0
  - openssl=1.1.1k=h2bbff1b_0
  - pandas=1.2.3=py37hf11a4ad_0
  - pefile=2019.4.18=py_0
  - pip=21.0.1=py37haa95532_0
  - pycryptodome=3.10.1=py37h2bbff1b_0
  - pyinstaller=3.6=py37h8cc25b3_6
  - pyparsing=2.4.7=pyhd3eb1b0_0
  - pyqt=5.9.2=py37h6538335_2
  - python=3.7.10=h6244533_0
  - python-dateutil=2.8.1=pyhd3eb1b0_0
  - pytz=2021.1=pyhd3eb1b0_0
  - pywin32=227=py37he774522_1
  - pywin32-ctypes=0.2.0=py37_1001
  - qt=5.9.7=vc14h73c81de_0
  - scipy=1.6.2=py37h14eb087_0
  - seaborn=0.10.1=py_0
  - setuptools=52.0.0=py37haa95532_0
  - sip=4.19.8=py37h6538335_0
  - six=1.15.0=py37haa95532_0
  - sqlite=3.35.4=h2bbff1b_0
  - tornado=6.1=py37h2bbff1b_0
  - vc=14.2=h21ff451_1
  - vs2015_runtime=14.27.29016=h5e58377_2
  - wheel=0.36.2=pyhd3eb1b0_0
  - wincertstore=0.2=py37_0
  - zlib=1.2.11=h62dcd97_4
prefix: C:\Users\alina\.conda\envs\test_env

标签: pythonmatplotlibseabornpyinstallerexecutable

解决方案


经过大量测试后,我意识到只有在使用conda环境创建可执行文件时才会发生这种情况。我只是创建了一个venv而不是一个conda环境,一切都很顺利。conda当您想使用pyinstaller.


推荐阅读