Python Jupyter:安装新模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40877408/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 00:07:52  来源:igfitidea点击:

Jupyter: install new modules

pythonanacondajupyter-notebookjupyterscitools

提问by Johnathan

I have recently installed Anaconda with Python 3.5 and all the rest. I come from R where I am used to install packages dynamically. I am trying to install a module called scitools through jupyter notebook. I would like to recreate this in jupyter. However, I don't know how to dynamically install packages (if it's possible). I would greatly appreciate your help. Thank you!

我最近用 Python 3.5 和所有其他版本安装了 Anaconda。我来自 R,我习惯于动态安装软件包。我正在尝试通过 jupyter notebook 安装一个名为 scitools 的模块。我想在 jupyter 中重新创建它。但是,我不知道如何动态安装软件包(如果可能的话)。我将不胜感激您的帮助。谢谢!

enter image description here

在此处输入图片说明

EDIT: I am trying to use conda as recommended by the community, but it's not working. I am using mac OSX

编辑:我正在尝试按照社区的推荐使用 conda,但它不起作用。我正在使用 Mac OSX

enter image description here

在此处输入图片说明

回答by Steve D.

So if you have already done the install with anaconda, you may already have the module installed. In that case in your jupyter notebook after you have activated your kernel, you just need to make sure you execute the import statement.

因此,如果您已经使用 anaconda 完成安装,那么您可能已经安装了该模块。在这种情况下,在您激活内核后的 jupyter notebook 中,您只需要确保执行 import 语句。

import scitools

If you haven't installed that module yet, you can install it one of two ways. Both work from your command line or terminal.

如果您尚未安装该模块,则可以通过以下两种方式之一进行安装。两者都可以从您的命令行或终端运行。

pip install scitools

or since you have Anaconda

或者因为你有 Anaconda

conda install scitools

and that should do it. Your import statement in your notebook when executed should correctly locate and enable the use of that module.

那应该这样做。执行时笔记本中的 import 语句应正确定位并启用该模块的使用。

回答by AB Abhi

Check Jake Vander Plus Blog hereto learn how to install a package with pip from Jupyter Notebook.

在此处查看 Jake Vander Plus 博客 ,了解如何使用 Jupyter Notebook 中的 pip 安装包。

# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install numpy

回答by cjremley

I had the same issue. It turns out if you open an anaconda window, which in Windows is accessible under the Anaconda drop down, it points to the correct location to install (or update) using pip.

我遇到过同样的问题。事实证明,如果您打开一个 anaconda 窗口(在 Windows 中可在 Anaconda 下拉菜单下访问该窗口),它会指向使用 pip 安装(或更新)的正确位置。