python jupyter笔记本和colab中'%pip'和'!pip'之间的区别

Ber*_*end 11 pip jupyter-notebook google-colaboratory

'!pip' 和 '%pip' 之间有什么区别?我们可以在 jupyter notebook 和 google colab 中使用它们。但我们不能在那里使用简单的“pip”,可以吗?

x4k*_*k3p 9

%pip是一个神奇的函数,其工作原理与 基本相同pip。您可以在 jupyter 中使用其他神奇功能,您可以将其列出%lsmagic

https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-lsmagic

使用!允许运行类似lspip或 操作系统上可用的命令。

Colab 就像 jupyter 一样,因此您可以pippip install tensorflow.

参见相关回答:


Vis*_*hal 7

%pip将在当前笔记本内核运行的虚拟环境中安装该软件包。同时!pip将在基础环境中安装该软件包。如果您正在使用 Python 虚拟环境(您应该这样做!),您应该使用%pip.