In this tutorial you will learn how to run python program in sublime text in windows.
在本教程中,您将学习如何在Windows的高级文本中运行python程序。
Just follow below steps to configure sublime text. The whole process is divided into two parts.
只需按照以下步骤配置崇高文本。 整个过程分为两部分。
第1部分:设置路径 (Part 1: Setting Path)
First of all you have to set the path of python installation directory in environment variable. You can skip this step if it is already done.
首先,您必须在环境变量中设置python安装目录的路径。 如果已经完成,则可以跳过此步骤。
1. Copy the path of python installation directory. In my case it looks like as shown below.
1.复制python安装目录的路径。 就我而言,如下所示。
C:\Users\TCP\AppData\Local\Programs\Python\Python36-32
C:\ Users \ TCP \ AppData \ Local \ Programs \ Python \ Python36-32
Note: Here TCP is the user name of my computer. It will be different in your case.
注意:此处的TCP是我计算机的用户名。 您的情况将有所不同。
2. Now right click on Computer and click on Properties option. Then select Advance system settings in left sidebar.
2.现在,右键单击计算机 ,然后单击属性选项。 然后在左侧栏中选择高级系统设置 。
3. Now click on Environment Variables and then under System variables select variable with name Path.
3.现在,单击环境变量 ,然后在系统变量下选择名称为Path的变量。
4. Click Edit button and then in Variable value field go to end and type semicolon and then paste the path of python directory that you copied. See below screenshot.
4.单击“ 编辑”按钮,然后在“ 变量值”字段中结束并键入分号,然后粘贴您复制的python目录的路径。 请参见下面的屏幕截图。
5. Finally click on all OK buttons to save the settings.
5.最后单击所有确定按钮以保存设置。
第2部分:安装SublimeREPL插件 (Part 2: Install SublimeREPL Plugin)
For taking input from user in sublime text we need a plugin named as SublimeREPL. So follow below steps to install it.
为了接受来自用户的崇高文本输入,我们需要一个名为SublimeREPL的插件。 因此,请按照以下步骤进行安装。
1. Go to below link and copy the code according to your sublime text version.
1.转到下面的链接,然后根据您的崇高文本版本复制代码。
https://packagecontrol.io/installation
https://packagecontrol.io/installation
2. Open sublime and go to View > Show Console. Then in console box at bottom paste the code that you have just copied and press enter. Wait for few seconds, it will install required packages.
2.打开sublime并转到查看>显示控制台 。 然后在底部的控制台框中粘贴刚刚复制的代码,然后按Enter。 等待几秒钟,它将安装所需的软件包。
3. Then go to Preferences > Package Control > Package Control: Install Package.
3.然后转到首选项>程序包控制>程序包控制:安装程序包。
4. In textbox type SublimeREPL and select it to install the plugin. After installation restart sublime text.
4.在文本框中,输入SublimeREPL并选择它以安装插件。 安装后,重新启动sublime文本。
5. Now got to Tools > Build System > New Build System. A new file will open, just paste the following code in it.
5.现在进入Tools> Build System> New Build System 。 将打开一个新文件,只需将以下代码粘贴到其中。
|
1
2
3
4
5
|
{
"target": "run_existing_window_command",
"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"
}
|
|
1
2
3
4
5
|
{
"target" : "run_existing_window_command" ,
"id" : "repl_python_run" ,
"file" : "config/Python/Main.sublime-menu"
}
|
6. Press ctrl + s and save it with file name Python_RUN.
6.按ctrl + s并将其保存为文件名Python_RUN 。
7. Go to Tools > Build System and select Python_RUN as build system or you can use ctrl + b as shortcut.
7.转到工具>构建系统,然后选择Python_RUN作为构建系统,或者可以使用ctrl + b作为快捷方式。
8. For running a python program go to Tools > Build.
8.要运行python程序,请转至工具>构建。
影片教学 (Video Tutorial)
Comment below if you are facing any problem to run python program in sublime text.
如果您在升华文字中运行python程序时遇到任何问题,请在下面评论。
翻译自: https://www.thecrazyprogrammer.com/2017/04/how-to-run-python-program-in-sublime-text.html