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

Mac安装Python后执行代码提示[Errno 13] Permission denied的解决方法

Hey there, let's work through this permission denied error you're hitting when running a Build in Sublime Text after setting up Python on your Mac. Here are actionable steps to fix it:

Troubleshooting & Fixes

1. Verify Python Interpreter Permissions

First, check if the Python 3.5 interpreter you're using has execution rights. Open up Terminal and run:

ls -l /usr/local/bin/python3.5

Look at the permission string (the first column of the output). If you don't see an x in the user, group, or others section (like -rw-r--r--), you need to add execute permissions:

sudo chmod +x /usr/local/bin/python3.5

When prompted, enter your Mac user password (Terminal won't show characters as you type—this is normal).

2. Resolve Python Version Conflicts

Looking at your path, there are multiple entries for Python 3.6, but your Build command is calling Python 3.5. This mismatch can cause permission or execution issues. Let's align Sublime with your system's default Python 3:

  • First, confirm which Python 3 your system uses by running in Terminal:
    which python3
    
    You'll likely get a path pointing to Python 3.6, like /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.
  • Now update your Sublime Build System to use this default:
    1. In Sublime Text, go to Tools → Build System → New Build System.
    2. Replace the default text with this JSON:
      {
          "cmd": ["python3", "-u", "$file"],
          "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
          "selector": "source.python"
      }
      
    3. Save the file as Python3.sublime-build (the default save location is correct: Packages/User).
    4. Select this new build system via Tools → Build System → Python3, then re-run your Build.

3. Check Your Script's File Permissions

It's possible your test-module.py file doesn't have read permissions for Sublime to access it. Verify with:

ls -l /Users/peter/Library/Application\ Support/Sublime\ Text\ 3/Packages/User/test-module.py

If read permissions are missing, add them with:

chmod +r /Users/peter/Library/Application\ Support/Sublime\ Text\ 3/Packages/User/test-module.py

If the above steps don't work immediately, you can try launching Sublime with elevated permissions to bypass the issue temporarily. In Terminal, run:

sudo open /Applications/Sublime\ Text.app

Enter your password when prompted, then try your Build again. Note: This is a quick workaround—fixing the root permission/version issues is better for long-term stability.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 04:41:42