首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在Pyinstaller中导入matplotlib

无法在Pyinstaller中导入matplotlib
EN

Stack Overflow用户
提问于 2021-12-08 10:07:19
回答 1查看 203关注 0票数 0

试图导入matplotlib并运行pyinstaller test.py生成的文件会导致错误:

代码语言:javascript
复制
Fatal Python error: _PyInterpreterState_Get(): no current thread state
Python runtime state: unknown

在使用Pyinstaller从.exe文件中创建.py文件时,导入任何其他包都可以正常工作,只有matplotlib才会出现错误。只需使用.py创建一个import matplotlib.pyplot as plt文件,就可以再现此错误。

来自pipdeptree:

代码语言:javascript
复制
pyinstaller==4.5.1
  - altgraph [required: Any, installed: 0.17.2]
  - pefile [required: >=2017.8.1, installed: 2021.9.3]
    - future [required: Any, installed: 0.18.2]
  - pyinstaller-hooks-contrib [required: >=2020.6, installed: 2021.4]
  - pywin32-ctypes [required: >=0.2.0, installed: 0.2.0]
  - setuptools [required: Any, installed: 59.5.0]

- matplotlib [required: >=3, installed: 3.5.0]
  - cycler [required: >=0.10, installed: 0.11.0]
  - fonttools [required: >=4.22.0, installed: 4.28.3]
  - kiwisolver [required: >=1.0.1, installed: 1.3.2]
  - numpy [required: >=1.17, installed: 1.21.4]
  - packaging [required: >=20.0, installed: 21.3]
    - pyparsing [required: >=2.0.2,!=3.0.5, installed: 3.0.6]
  - pillow [required: >=6.2.0, installed: 8.4.0]
  - pyparsing [required: >=2.2.1, installed: 3.0.6]
  - python-dateutil [required: >=2.7, installed: 2.8.2]
    - six [required: >=1.5, installed: 1.16.0]
  - setuptools-scm [required: >=4, installed: 6.3.2]
    - packaging [required: >=20.0, installed: 21.3]
      - pyparsing [required: >=2.0.2,!=3.0.5, installed: 3.0.6]
    - setuptools [required: Any, installed: 59.5.0]
    - tomli [required: >=1.0.0, installed: 1.2.2]

我尝试过不同版本的matplotlib,但错误仍然存在。我也不知道我应该尝试哪种版本。导入matplotlib以前以前经常工作,但我不知道当时我使用的是什么matplotlib版本(或任何依赖项的版本)。我在Windows上,使用虚拟环境并根据https://pyinstaller.readthedocs.io/en/stable/bootloader-building.html构建引导加载程序

EN

回答 1

Stack Overflow用户

发布于 2021-12-08 11:20:56

按照这里的建议,通过专门的matplotlib==3.2.2来修正如何在使用matplotlib时使用pyinstaller的另一个问题

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70273176

复制
相关文章

相似问题

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