Cannot import matplotlib into Python 3

痴心易碎 提交于 2019-12-10 21:17:34

问题


I am attempting to teach myself programming and keep running into problems downloading modules I need for basic tutorials.

My latest attempt has been to get the matplotlib module into my Python 3 environment. I have tried so many different install packages and so many advice I found on the internet that I cannot remember how I originally got the module. But it seemed that everything went well with the installation process.

I am using a Raspberry Pi2 throughout all of this with the Raspbian OS installed.

Python 3.2.3 (default, Mar  1 2013, 11:53:50)
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import matplotlib
ImportError: No module named matplotlib

回答1:


It may be possible that you actually installed the library for python 2. I would use pip to install the modules that you need. If you don't already have it installed, run this first command in the shell:

sudo apt-get install python3-pip

This program can be called with "pip3" or maybe "pip-3.2" in the shell.

To install mathplotlib with it, try running:

pip3 install matplotlib

or

pip-3.2 install matplotlib

That should install the Python 3 module for you.



来源:https://stackoverflow.com/questions/34185797/cannot-import-matplotlib-into-python-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!