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

查看:61
本文介绍了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/python2python3/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 并且我还在 sys.path 中附加了/home//anaconda2/pkgs".

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:UsersFelix>conda info --envs
# conda environments:
#
ipykernel_py2            D:Anacondaenvsipykernel_py2
root                  *  D:Anaconda

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

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

C:UsersFelix>activate ipykernel_py2

(ipykernel_py2) C:UsersFelix>

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

Finally, use pip to install the required packages:

(ipykernel_py2) C:UsersFelix>pip install matplotlib
Collecting matplotlib
...
Successfully installed matplotlib-2.0.0

希望这会有所帮助.

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

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