[英]Matplotlib won't work in python even though i pip installed it
我正在尝试使用 matplotlib 进行一些绘图。
我写:
import matplotlib as mpl
import matplotlib.pyplot as plt
当我尝试运行程序时,我得到:
import matplotlib as mpl
ModuleNotFoundError: No module named 'matplotlib'
这不应该发生,因为我已经将 pip 安装到 matplotlib 到最新版本(3.5.1)并且 matplotlib 在终端中正确显示时显示。 为什么 matplotlib 不起作用?
看起来你搞砸了 Python 安装。 也许pip
在一个 Python 中安装了一些东西,但是python
调用另一个版本,它没有你想要的库。
To get sure you're installing and running with the same Python, replace python -m pip
with python[version] -m pip
, and python my_file.py
with python[version] my_file.py
. 例如,要使用 Python 3.9,请使用python3.9
而不是python
。 等等。
有了这个,您可以确保使用相同的 Python 安装和运行东西。 此外,最好尝试虚拟环境,而不是与全局安装作斗争。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.