Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 在任何地方使用终端运行python代码_Python 3.x_Ubuntu_Terminal_Ubuntu 16.04 - Fatal编程技术网

Python 3.x 在任何地方使用终端运行python代码

Python 3.x 在任何地方使用终端运行python代码,python-3.x,ubuntu,terminal,ubuntu-16.04,Python 3.x,Ubuntu,Terminal,Ubuntu 16.04,我是Ubuntu新手,我似乎无法让我的python程序在计算机的任何地方与终端一起工作 以下是我迄今为止所做的: 我的代码的第一行:#/usr/bin/python 端子:chmod+x archiveur.py 终端:sudo cp archiveur.py/usr/local/bin 现在,每次我在终端中编写命令时,它都会告诉我找不到该命令 如何调用我的命令atm: python archiveur.py arg1 arg2 我实际上想怎么称呼它: 档案arg1 arg2 我做错了什么

我是Ubuntu新手,我似乎无法让我的python程序在计算机的任何地方与终端一起工作

以下是我迄今为止所做的:

  • 我的代码的第一行:#/usr/bin/python
  • 端子:chmod+x archiveur.py
  • 终端:sudo cp archiveur.py/usr/local/bin
现在,每次我在终端中编写命令时,它都会告诉我找不到该命令

如何调用我的命令atm:

python archiveur.py arg1 arg2

我实际上想怎么称呼它:

档案arg1 arg2

我做错了什么


谢谢。

您能给出“哪种python”的结果吗?因为您只需键入以下命令“python archiveur.py”/usr/bin/python即可运行您的程序。我需要执行我的程序,而不必写入“python archiveur.py”,只需在有archiveur程序的终端键入“archiveur arg1 arg2…”“/archiveur.py arg1 arg2编辑了线程,因为我意识到缺少一个信息,实际上我需要像这样调用我的命令:archiveur arg1 arg2。这是一个家庭作业,我错过了最后一部分,我用.bat在windows上完成了这项工作,但我不知道Ubuntu是如何创建命令的。@MaxyArthes…在这里要求家庭作业是完全不好的…但是对于你的orientashion…你需要在你的bashrc文件中创建一个别名…或者写一个bash脚本并将其命名为archiveur,从而将参数传递给你的python脚本