简体   繁体   English

在Mac上导入matplotlib错误

[英]import matplotlib error on mac

Um... I wanted to import matplotlib in Python IDLE, but it said 嗯...我想在Python IDLE中导入matplotlib,但是它说

>>> import matplotlib
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    import matplotlib
ModuleNotFoundError: No module named 'matplotlib'

I've already tried pip thing and the conda thing in terminal. 我已经在终端中尝试过pip和conda了。 It said 它说

# All requested packages already installed.
# packages in environment at /Users/Dan/anaconda:

Then! 然后! what's the problem here? 这是什么问题?

I had the same issue using the same command in IDLE. 我在IDLE中使用相同的命令遇到了相同的问题。 I just figured it out. 我只是想通了。 go to your terminal and enter: 转到您的终端并输入:

pip3.6 install matplotlib

I was using pip3 instead of pip3.6 我使用的是pip3而不是pip3.6

You may have installed Matplotlib to Python 2.7 and not Python 3.6. 您可能已将Matplotlib安装到Python 2.7,而不是Python 3.6。 To install it to Python3 you need to use pip3: 要将其安装到Python3,您需要使用pip3:

pip3 install matplotlib

Then open python3.6 from your terminal (not idle) and try importing matplotlib from there. 然后从您的终端(不是空闲的)中打开python3.6,然后尝试从那里导入matplotlib。 This way you can use any text editor you wish, and run your code from the terminal. 这样,您可以使用所需的任何文本编辑器,并从终端运行代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM