top of page
  • Writer's pictureLuke Chikkala

Building Python scripts in Sublime Text (on Windows)

Install Python

  • Download Python [python-3.10.5-amd64.exe] to:

C:\dev\python\
  • Choose Customize Installation

  • Enable only:

pip
tcl/tk and IDLE
  • Disable all options and install to a known specific location:

C:\dev\python\install
 

Set PATH

  • Copy the location of python's Scripts:

C:\dev\python\install\Scripts
  • Open Advanced System Properties from Run:

SystemPropertiesAdvanced
  • Edit 'Path' variable from 'Use variables for Chikkala'

  • Add New

  • Paste the location of python Scripts

  • Open a new Command Prompt window and type:

echo %PATH%
 

Installing Virtual Environment

  • Open Command Prompt

  • Navigate to python's Scripts directory:

cd /d C:\dev\python\install\Scripts
  • Install Virtual Environment:

pip  install virtualenv
 

Create Virtual Environment

virtualenv c:\dev\python\pyEnv\
 

Setup Sublime's Build System

  • Tools Build SystemNew Build System...

  • Default Script:

{
	"shell_cmd": "make"
}
  • Change this to:

{
	"cmd": ["C:/dev/python/install/python.exe", "$file"],
	"selector": "source.python",
	"file_regex": "^\\s*File \"(...*?)\", line ([0-9]*)"
}

or to set the build system to use python's virtual environment, set it to:

{
	"cmd": ["C:/dev/python/pyEnv/Scripts/python.exe", "$file"],
	"selector": "source.python",
	"file_regex": "^\\s*File \"(...*?)\", line ([0-9]*)"
}
  • Save it as 'Python_Build' under:

C:\Users\%USERNAME%\AppData\Roaming\Sublime Text\Packages\User
 

Test Python Script

  • Create a python test script:

print('test')
  • Save it!

  • Set the Build System in:

Tools Build SystemPython_Build

  • Build [Ctrl + B] !

41 views0 comments

Recent Posts

See All
Post: Blog2_Post
bottom of page