use*_*502 30 python-3.x sublimetext3
我按照这些步骤在Sublime Text 3上运行Python 3.
选择菜单工具>构建>新构建系统,然后输入以下内容:
{
"cmd": ["python3", "$file"]
, "selector": "source.python"
, "file_regex": "file \"(...*?)\", line ([0-9]+)"
}
Run Code Online (Sandbox Code Playgroud)
之后,我将其保存到以下(特定于Mac)目录:〜/ Library/Application Support/Sublime Text 3/Packages/User
但是当我在Sublime中尝试在Python 3上运行我的代码时,我遇到了这个错误:
[Errno 2] No such file or directory: 'python3'
Run Code Online (Sandbox Code Playgroud)
And*_*rew 39
您需要提供python3的完整路径,因为Sublime Text不会读取您的~/.bash_profile文件.打开终端,键入which python3并使用完整路径:
{
"cmd": ["path/to/python3", "$file"],
"selector": "source.python",
"file_regex": "file \"(...*?)\", line ([0-9]+)"
}
Run Code Online (Sandbox Code Playgroud)
NYC*_*yes 25
这是我一直在使用的片段.这是Andrew的解决方案的一个细微变化,通过查询UNIX环境的PATH设置动态定位 python3 (与在Python shell脚本中执行相同操作的方式不同;例如:' #!/ usr/bin/env python3 ') .
此片段还使用" shell_cmd "而不是" cmd ",sublime-text-3似乎已切换到.
{
"shell_cmd": "/usr/bin/env python3 ${file}",
"selector": "source.python",
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"working_dir": "${file_path}",
}
Run Code Online (Sandbox Code Playgroud)
我在" .../Packages/User/Python3.sublime-build "中保存了我的.我希望这可以帮助你.= :)
| 归档时间: |
|
| 查看次数: |
41743 次 |
| 最近记录: |