jupyter笔记本导入错误:没有名为"matplotlib"的模块 [英] jupyter notebook import error: no module named 'matplotlib'

查看:244
本文介绍了jupyter笔记本导入错误:没有名为"matplotlib"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是ubuntu 16.4用户,我安装了anaconda3并同时使用python2和python3内核.

I'm an ubuntu 16.4 user and I installed anaconda3 and using both python2 and python3 kernels.

>>> jupyter内核规格列表 可用内核: python2/home/peterkim/.local/share/jupyter/kernels/python2 python3/home/peterkim/anaconda3/share/jupyter/kernels/python3

>>>jupyter kernelspec list Available kernels: python2 /home/peterkim/.local/share/jupyter/kernels/python2 python3 /home/peterkim/anaconda3/share/jupyter/kernels/python3

和..问题是我不知道在哪里/如何安装软件包,以便让我的python2 jupyter笔记本不出现错误未命名为...的模块". 我尝试了pip install matplotlibconda install matplotlib,并且还将'/home//anaconda2/pkgs'附加到了sys.path.

and.. the problem was that I don't know where/how to install packages in order to for my python2 jupyter notebook not to make error 'no module named ...'. I tried pip install matplotlib and conda install matplotlib and I also appended '/home//anaconda2/pkgs' to the sys.path.

(我还安装了anaconda2来寻找使用并行内核的方式.在意识到不需要anaconda2之后,但没有卸载它.)

(I also installed anaconda2 in search of the way of using parallel kernels. After I realised that anaconda2 was not needed. but I didn't uninstall it.)

感谢您提前帮助我..

推荐答案

我建议在这里通读:

https://conda.io/docs/py2or3.html

在Anaconda3安装程序中安装Python 2.7环境后,我遇到了同样的问题.我不确定我用来创建环境的命令,但实际上并没有安装通常与Anaconda捆绑在一起的所有可选软件包(例如matplotlib,numpy等).但这不是什么大问题,您可以按照以下步骤通过pip轻松安装其他软件包:

I had the same problem after installing a Python 2.7 environment inside my Anaconda3 installation. I'm not sure which command I used to create the environment, but it actually didn't install all the optional packages that are usually bundled with Anaconda (like matplotlib, numpy, ...). But that's not a big issue, you can easily install additional packages with pip as follows:

首先,列出您的conda环境:

First, list your conda environments:

C:\Users\Felix>conda info --envs
# conda environments:
#
ipykernel_py2            D:\Anaconda\envs\ipykernel_py2
root                  *  D:\Anaconda

接下来,使用source activate <env>(Linux/OSX)或activate <env>(Windows)激活python 2环境:

Next, activate your python 2 environment using source activate <env> (Linux/OSX) or activate <env> (Windows):

C:\Users\Felix>activate ipykernel_py2

(ipykernel_py2) C:\Users\Felix>

最后,使用pip安装所需的软件包:

Finally, use pip to install the required packages:

(ipykernel_py2) C:\Users\Felix>pip install matplotlib
Collecting matplotlib
...
Successfully installed matplotlib-2.0.0

希望这会有所帮助.

这篇关于jupyter笔记本导入错误:没有名为"matplotlib"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆