我一直试图在我的计算机上运行一个使用 matplotlib 的程序,但是每当我运行它时,我都会收到以下错误:
ImportError: No module named 'matplotlib'
到目前为止,我已经尝试通过以下方式安装它:pip install matplotlib
pip3 install matplotlib
python3 -m pip install matplotlib
sudo apt-get install python3-matplotlib
它设法工作的唯一方法是如果我通过 anaconda 安装它,但在我卸载它之后,它又开始显示错误消息。我正在使用 Ubuntu,并且我已经编辑了我的 .bashrc 文件以包含这些行:export PYTHON=python3
alias python=python3
anaconda 是唯一解决方案的原因可能是什么?为什么卸载后它不能继续工作?
最佳答案
您可以尝试以下方法:
从终端运行:
python3 -m pip install matplotlib
如果这不起作用,请从终端尝试:easy_install matplotlib
如果这也不起作用,请尝试打开 python 解释器(终端中的 python3
)并在 python 解释器中运行以下命令:import pip
pip.main(["install","matplotlib"])
关于python - 导入 matplotlib 时出错,除非使用 anaconda,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67782839/