答案:通过创建自定义Build System可指定Python解释器路径和运行参数。1. 在Tools→Build System→New Build System中创建新配置;2. 编辑JSON内容,设置cmd为python路径及-u $file参数,确保shell为true;3. 保存为Python_Custom.sublime-build;4. 在Build System中选择该配置;5. 可选项目级默认设置。修改后运行更稳定,适合多版本或虚拟环境用户。

点击菜单栏的 Tools → Build System → New Build System...,会打开一个JSON格式的配置文件模板。
将默认内容替换为以下内容(根据你的Python路径调整):
{ "cmd": ["python", "-u", "$file"], "file_regex": "^[ ]*File "(...*?)", line ([0-9]*)", "selector": "source.python", "shell": true }说明:
python;否则建议写完整路径,如:"C:/Python39/python.exe" 或 "C:\Users\YourName\AppData\Local\Programs\Python\Python39\python.exe"
保存为 Python_Custom.sublime-build(名称可自定义),保存位置使用默认路径即可。
立即学习“Python免费学习笔记(深入)”;
回到 Tools → Build System,选择你刚刚保存的 Python_Custom。
之后按 Ctrl + B 运行Python脚本时,就会使用你指定的解释器。
虽然Sublime不支持直接“覆盖”默认Python build system,但你可以:
Python.sublime-build(不推荐)基本上就这些。改完之后运行Python脚本会更稳定,尤其适合有多个Python版本或使用虚拟环境的用户。关键是把路径写对,其他都不复杂但容易忽略。
以上就是sublime怎么修改默认的python build system_sublime Python默认编译系统修改的详细内容,更多请关注php中文网其它相关文章!
python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号