简体   繁体   English

Jupyter Notebook 如何判断您输入的命令是终端命令还是 python 命令?

[英]How does Jupyter notebook tell is a command you typed is a terminal command or python command?

I just found that without typing "."我只是发现没有输入“。” you can still run some terminal commands in the Jupyter notebook, Such as, "ls", "pwd", "cd".您仍然可以在 Jupyter notebook 中运行一些终端命令,例如“ls”、“pwd”、“cd”。 etc, But when I try to run some other terminal command, for example, "tree": it tells me "NameError. name 'tree' is not defined".等等,但是当我尝试运行其他一些终端命令时,例如“tree”:它告诉我“NameError。名称'tree'未定义”。 It means that Jupyter notebook is interpreting that command as a Python command.这意味着 Jupyter notebook 将该命令解释为 Python 命令。

Question: how does Jupyter tell if a command is a terminal command or Python command when you don't type "?"问题:当您不输入“?”时,Jupyter 如何判断命令是终端命令还是 Python 命令? before the terminal command?在终端命令之前?

Jupyter has a set of shell-like commands that it recognizes regardless of whether you add a ! Jupyter 有一组类似 shell 的命令,无论您是否添加! in front of them or not (given that your automagic is set to on, otherwise you have to prefix them with ! ).在他们面前或不在他们面前(假设你的automagic设置为开,否则你必须在他们前面加上! )。 Some of the most common include cd , cat , cp , man , rm or pwd .一些最常见的包括cdcatcpmanrmpwd The full list is available here .完整列表可在此处获得

Unfortunately tree is not one of these commands, so you'd be better off executing that in a dedicated shell.不幸的是tree不是这些命令之一,所以你最好在专用的 shell 中执行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM