python - 错误 : no such file

标签 python linux terminal

我能够下载 IDLE。我 chmod 使其可执行。但每当我运行 .py 文件时。我得到错误:每行开头没有这样的文件。它在 IDLE 模块中运行良好,但当我尝试在终端中运行时,我遇到了这个问题。

~/Desktop/PythonScripts# ./calculator.py Error: no such file "Welcome to my Calculator Program." Error: no such file "You will be able to do basic calculations." Error: no such file "Such as addition, subtraction, multiplication and division." Error: no such file ":For addition press 1: " Error: no such file ":For subtraction press 2: " Error: no such file ":For multiplication press 3: " Error: no such file ":For division press 4: "

我想知道如何解决这个问题,谢谢。

最佳答案

您是否在脚本开头添加了 python 位置?如果你跑

which python

它会给你类似的位置

/usr/bin/python

在你的脚本的开头添加这个

#!/usr/bin/python

关于python - 错误 : no such file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46333669/

相关文章:

python - Cython setup error : Unable to find pgen, 没有编译正式语法

python - 在 Python 中从 OrderedDict 访问数据并对其进行循环

python - 将.mat文件加载到Python后如何获取字符串

linux - 用于终止父进程 1 的已失效进程的脚本

linux - 为什么在尝试远程桌面时出现 SSL_read 错误和 Rpc_client_frag_read 错误

python - 如何理解和解决PLY中的冲突

C++ ofstream,不带 CRLF 的打印

linux - 重命名包含特殊字符的文件夹中的文件 linux

emacs - Multiterm背景颜色错误

bash - 如何使用 bash 删除和替换终端中的最后一行?