我以为我们可以在Jupyter单元格中通过运行如下类似的命令来运行PIP Install或PIP uninstall。
%pip install myPackage
但是我被提示需要确认,类似于这样:
是否继续 (y/n)?
我该如何克服这个问题并在单元格中运行PIP?
我以为我们可以在Jupyter单元格中通过运行如下类似的命令来运行PIP Install或PIP uninstall。
%pip install myPackage
但是我被提示需要确认,类似于这样:
是否继续 (y/n)?
我该如何克服这个问题并在单元格中运行PIP?
你尝试过这种安装方式,而不是使用魔法吗?
!pip install <package>
通常这不应该提示您继续。
顺便问一下,您要安装哪个软件包?我已经尝试了使用!pip
和%pip
两种方式。使用%pip
时没有提示我继续,但要求我重启内核。
%pip install folium
Collecting folium
Downloading https://files.pythonhosted.org/packages/c3/83/e8cb37afc2f016a1cf4caab8d22caf7fe4156c4c15230d8abc9c83547e0c/folium-0.12.1-py2.py3-none-any.whl (94kB)
Requirement already satisfied: requests in c:\users\by20064109\appdata\local\continuum\anaconda3\lib\site-packages (from folium) (2.22.0)
Requirement already satisfied: branca>=0.3.0 in c:\users\by20064109\appdata\local\continuum\anaconda3\lib\site-packages (from folium) (0.4.2)
Requirement already satisfied: numpy in c:\users\by20064109\appdata\local\continuum\anaconda3\lib\site-packages (from folium) (1.16.4)
Requirement already satisfied: jinja2>=2.9 in c:\users\by20064109\appdata\local\continuum\anaconda3\lib\site-packages (from folium) (2.10.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\by20064109\appdata\local\continuum\anaconda3\lib\site-packages (from requests->folium) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\by20064109\appdata\local\continuum\anaconda3\lib\site-packages (from requests->folium) (1.24.2)
Requirement already satisfied: idna<2.9,>=2.5 in c:\users\by20064109\appdata\local\continuum\anaconda3\lib\site-packages (from requests->folium) (2.8)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\by20064109\appdata\local\continuum\anaconda3\lib\site-packages (from requests->folium) (2019.6.16)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\by20064109\appdata\local\continuum\anaconda3\lib\site-packages (from jinja2>=2.9->folium) (1.1.1)
Installing collected packages: folium
Successfully installed folium-0.12.1
Note: you may need to restart the kernel to use updated packages.
%pip install
和%conda install
,您在现代Jupyter中的体验将更加流畅,因为现代魔术命令是为了确保安装发生在与内核运行的同一环境中。在这里了解更多关于现代魔术安装命令的信息。 - undefined使用yes
命令代替魔术命令如何?
! yes| pip install myPackage
conda
吗?我猜你是这样做的,因为我知道这个包管理器会询问“是否继续(y/n)?”如果 conda
在你的 jupyter 上通过 %pip
运行,那么 !conda install myPackage -y
可以进行静默安装。pip
没有 --yes
选项用于 pip install
。 - Chachay!pip install package_name
从这篇文章开始 https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/
import sys
!{sys.executable} -m pip install numpy
import os
os.system('ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts')
vi ~/.local/share/jupyter/kernels/rag/kernel.json
which python
/home/user/miniconda3/envs/rag/bin/python
change the python binary path to the one from which python in the active conda environment
vi ~/.local/share/jupyter/kernels/rag/kernel.json
{
"argv": [
"/home/user/miniconda3/envs/rag/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "rag",
"language": "python",
"metadata": {
"debugger": true
}
}
~
pip --help
的输出,有一个--no-input
选项。我会尝试使用它。 - Paul Hpip install -y myPackage
- phd