【问题标题】:Cannot run internal or external commands in Jupyter Notebook无法在 Jupyter Notebook 中运行内部或外部命令
【发布时间】:2021-12-23 10:36:09
【问题描述】:

我正在尝试在 Jupyter 笔记本中运行 shell 命令,但它不起作用

!which python

显示错误

'which' is not recognized as an internal or external command,
operable program or batch file.

【问题讨论】:

    标签: shell jupyter-notebook anaconda


    【解决方案1】:

    如果您使用的是基于 Windows 的系统:

    !where python
    

    其他:

    %%bash
    which python
    

    参考资料:

    【讨论】:

    • 我收到此响应找不到程序:'bash'
    • @AhmedAlsonaffi 我认为您正在尝试在 Windows 操作系统上使用 unix 命令。检查我编辑的答案。
    • 我使用的是 Windows 10
    • 你试过答案的第一个代码吗?
    • @AhmedAlsonaffi 但您使用的是 Windows - 为什么 UNIX 命令应该可用?
    【解决方案2】:

    你能运行 python3 --version.我假设您使用的是 Windows。打开命令行并运行命令。如果您仍然得到相同的响应,则表示您在安装时没有将 python 添加到路径。你是用 Anaconda 安装的吗?

    如果您想将 python 添加到路径中,只需点击此链接即可。这是不言自明的。如果您仍有问题,请在评论部分告诉我。

    https://datatofish.com/add-python-to-windows-path/

    【讨论】:

    • 我在 cmd 中运行命令时得到相同的响应
    • 这意味着您没有将 python 添加到您的虚拟环境中。有两种方法可以解决这个问题。手动将python路径添加到环境变量或重新安装python并在弹出安装屏幕时单击添加到路径
    猜你喜欢
    • 1970-01-01
    • 2018-05-09
    • 1970-01-01
    • 2023-04-05
    • 2019-02-16
    • 1970-01-01
    • 2016-01-12
    • 1970-01-01
    • 2022-01-07
    相关资源
    最近更新 更多