在windows上的Jupyter笔记本中运行Linux命令时出错

2024-04-19 18:26:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在为Python研究熊猫。我正在做我的实际工作,在朱派特笔记本。我尝试在Jupyter notebook中运行几个Linux命令,结果如下:

enter image description here

如您所见,我可以运行ls命令,但不能运行cat命令。我尝试执行cat命令,就像!cat一样,但是它无法识别,如下所示:

enter image description here


Tags: 命令linux笔记本jupyterlscatnotebook
1条回答
网友
1楼 · 发布于 2024-04-19 18:26:09

从截图可以看出,IPython是错误消息的一部分。Jupyter notebook is using IPython当你在Windows中运行这些命令时。在

IPython documentation about magic commands:

For posix systems, the default aliases are ‘cat’, ‘cp’, ‘mv’, ‘rm’, ‘rmdir’, and ‘mkdir’, and other platform-specific aliases are added.

For windows-based systems, the default aliases are ‘copy’, ‘ddir’, ‘echo’, ‘ls’, ‘ldir’, ‘mkdir’, ‘ren’, and ‘rmdir’.

这就是为什么Linux ls可以工作,但是cat命令对Windows上的IPython不起作用。在

注意:IPython不是一个命令行工具。对于Windows上的Linux命令行工具,请尝试Cygwin。在

相关问题 更多 >