This guide shows you how to install the Python runtime on Windows. The following steps must be performed via RDP. If you don’t know how to connect to your server via RDP, please check out our First Access (RDP) guide.
Open your favorite browser (I’m using Chrome for this guide) and go to https://www.python.org/downloads/
Click the Download Python [Version] button and wait for the download to complete.
Start the installer by clicking it. You will be prompted to configure some installation settings. Make sure the checkbox Add python.exe to PATH at the bottom is checked (this makes running Python files much easier later) and then click Install Now.
Wait until all files are installed. Be patient, this can take a moment. :)
When the installation is finished, simply click Close and you can start using Python on your server.
Now that Python is installed on your server, you can start your Python programs.
If you enter the command python in the Command Prompt or PowerShell, the Python interpreter will start. You can now enter any valid Python code after the >>> prompt, which will be executed after pressing Enter. You can exit the interpreter with exit() or simply by closing the window.
To run .py Python files, simply use the command python [filename].py, replacing [filename] with the path to your desired file. You do this in the Command Prompt or PowerShell as well.
Most programs you find online can be started with python main.py since main.py is often the entry point for most Python programs.
You can also open Python (.py) files by double-clicking them or start them directly via right-click in Windows.
When programming with Python, you often need external packages that you install with pip. You can install these globally so all .py scripts can access them, or you can create a virtual environment (venv).
First, navigate in File Explorer to the folder where you want to set up your venv. Then run python -m venv . there to install the necessary files at the current location.
To run commands like pip install inside your venv, you need to activate it with .\Scripts\activate. From now on, your console runs only inside the venv and scripts access only locally installed packages.
When you’re done, you can leave the venv again with the command deactivate.