【问题标题】:Opening a python file in terminal. (Ubuntu)在终端中打开一个 python 文件。 (Ubuntu)
【发布时间】:2014-12-02 15:36:23
【问题描述】:

我今天刚刚安装了 ubuntu,我不知道如何运行我的 .py 文件。

我打开终端并输入 python test.py 并收到一条错误消息“python: can't open file 'test.py': [Errno 2] No such file or directory”

如果你能帮帮我,那就太好了。

谢谢

【问题讨论】:

    标签: python ubuntu command-line terminal


    【解决方案1】:

    python test.py 会尝试从当前目录执行 test.py。

    其他尝试给出 test.py 的完整路径

    像“python /usr/local/bin/test.py”

    【讨论】:

      【解决方案2】:

      您正在使用正确的命令打开它,但当前工作目录中没有 test.py 文件。

      尝试使用

      ls
      

      验证哪些文件实际上在您的工作目录中并使用

      cd path/goes/here
      

      将目录更改为文件所在的位置。

      那就试试python test.py

      【讨论】:

      • 好吧,我试了一下,但是没有任何反应。例如:george@George:~/this/is/my/path$ python test.py george@George:~/this/is/my/path$ 就是这样
      • 输入ls 并回车。返回什么?
      • 你需要找到 test.py 所在的确切位置。
      猜你喜欢
      • 1970-01-01
      • 2018-05-16
      • 1970-01-01
      • 2023-01-03
      • 2012-11-21
      • 1970-01-01
      • 1970-01-01
      • 2014-06-17
      • 2015-05-01
      相关资源
      最近更新 更多