python jupyter notebook 和 colab 中 '%pip' 和 '!pip' 的区别

difference between '%pip' and '!pip' in python jupyter notebook and colab

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

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

列出这些函数

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

使用 ! 允许 运行 命令,例如 lspip 或您在 OS.

上可用的命令

Colab 就像 jupyter,因此您可以 运行 本机 pip 就像 pip install tensorflow

查看相关答案:

  • What is %pylab?
  • How do I install Python packages in Google's Colab?