jupyter !和%
学习别人给到的 Jupyter 代码时,其中有安装依赖的代码 使用 1 !pip install numpy 这里我看到 vscode 插件提示我 但是据我测试,%pip 和 !pip 都是能正常执行的,我不是很明白 py note所以搜索了一下,盲猜和 python 环境是有关的 相关链接 Medium,Installing Python Packages in Jupyter Notebooks Trouble with pip installation - JupyterLab / extensions - Jupyter Community Forum Installing Python Packages from a Jupyter Notebook | Pythonic Perambulations 结论 !pip install :调用外部 Shell 在 Jupyter 中以 ! 开头的命令会被当作 Shell 命令 执行,比如直接调用系统或虚拟环境中的 pip: 1 !pip install numpy 它在新的子进程中执行,依赖于系统的 PATH 环境变量,可能会使用错误的 Python 解释器或 pip。 ...