You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Java项目执行bash脚本遇两类“No such file or directory”错误求助

解决你的脚本执行问题

Hey there, let's fix this step by step—no terminal expertise required, I'll keep it clear!

先搞懂两个报错的原因

1. 为什么去掉点会提示文件找不到?

When you changed the path to /runtime/updatemcp.py, that's an absolute path—it tells the system to look for a runtime folder directly in your system's root directory (/), not the folder you're currently in. That's why it can't find the file, even though runtime is right there with you. You need to keep the relative path: either ./runtime/updatemcp.py (the dot means "current directory") or just runtime/updatemcp.py (both work the same here).

2. 为什么保留点会提示python2: No such file or directory?

Your script is trying to run the Python 2 interpreter, but your system doesn't have it installed, or it's not available under the python2 command. Most modern systems default to Python 3 now, so we need to fix this part.


具体解决方法

Pick one of these options based on what works for your setup:

Option 1: Install Python 2 (if the script requires it)

If the updatemcp.py script only works with Python 2, install it via your system's package manager:

  • Ubuntu/Debian: Open terminal and run sudo apt update && sudo apt install python2
  • Mac (with Homebrew): Run brew install python@2

Once installed, run your script again: bash updatemcp.sh—it should find Python 2 now.

Option 2: Modify the script to use Python 3 (if the script is compatible)

If updatemcp.py works with Python 3 (many old scripts do now), edit your updatemcp.sh script:

  1. Open the script in a text editor (like nano updatemcp.sh in terminal)
  2. Change the second line to:
    python3 ./runtime/updatemcp.py "$@"
    
  3. Save and exit (in nano, press Ctrl+O, then Enter, then Ctrl+X)

Now run the script again—it'll use Python 3 instead of looking for Python 2.

If you have Python 2 installed but it's called something like python2.7 instead of python2, create a link so the system recognizes the python2 command:
Run sudo ln -s /usr/bin/python2.7 /usr/local/bin/python2 (replace /usr/bin/python2.7 with the actual path to your Python 2 executable if it's different).


Quick checks to confirm everything's in place

Before running the script again, verify these to avoid extra headaches:

  • Make sure you're in the right folder: Run ls and you should see updatemcp.sh and the runtime folder listed.
  • Confirm updatemcp.py exists: Run ls runtime and check for the file.
  • Verify your Python setup: Run python2 --version (if you installed it) or python3 --version to make sure the interpreter is working.

内容的提问来源于stack exchange,提问作者Miloertas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:26:09