【问题标题】:matplotlib doesn't save graph as file on raspberrypimatplotlib 不会将图形保存为 raspberrypi 上的文件
【发布时间】:2021-01-20 10:48:38
【问题描述】:

我对树莓派上的 matplotlib 有疑问 我有以下代码:

import matplotlib.pyplot as plt

data = [100, 200, 500, 700, 300, 200, 500]
x =[1, 2, 3, 4, 5, 6, 7]

plt.plot(x, data, color='w')
plt.xlabel('x axis')
plt.ylabel('y axis')
plt.savefig("test.png")

代码在我的计算机上运行良好,但在树莓派上我得到以下错误:

Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.7/site-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/home/pi/.local/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/home/pi/.local/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.27' not found (required by /home/pi/.local/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-arm-linux-gnueabihf.so)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "/home/pi/.local/lib/python3.7/site-packages/matplotlib/__init__.py", line 107, in <module>
    from . import cbook, rcsetup
  File "/home/pi/.local/lib/python3.7/site-packages/matplotlib/cbook/__init__.py", line 28, in <module>
    import numpy as np
  File "/home/pi/.local/lib/python3.7/site-packages/numpy/__init__.py", line 140, in <module>
    from . import core
  File "/home/pi/.local/lib/python3.7/site-packages/numpy/core/__init__.py", line 48, in <module>
    raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.7 from "/usr/local/bin/python3"
  * The NumPy version is: "1.19.4"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.27' not found (required by /home/pi/.local/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-arm-linux-gnueabihf.so)

pip3 freeze 说我的numpy版本是1.19.4

python3 --version说我的python版本是3.7.0

我该如何解决这个问题?

【问题讨论】:

    标签: python python-3.x numpy matplotlib raspberry-pi


    【解决方案1】:

    这为我解决了问题 要解决linux上的问题,需要安装以下包: sudo apt-get install libatlas-base-dev

    https://github.com/Pex2892/PETAL/issues/2

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-31
      • 2018-06-06
      • 1970-01-01
      • 2015-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多