hakk

software development, devops, and other drivel
Tree lined path

Install and Configure Embedded Python on Windows

I wanted to document these steps after downloading embedded Python recently. I extracted it, set the environment path and started the interpreter. Everything seemed to be going smoothly until I tried to exit exit() and it reported back ’exit not found’ or something like that. What!? How can this be? I ended up import sys and using sys.exit() but this sent me on an adventure to determine how to use embedded Python as a regular install.

These steps have been tested on Window 10, Server 2019 and Server 2022.

Download Python

First visit the Python website and select which version you would like to install. For this post I selected Python 3.12.0 but these steps will work with other versions.

Python website with embedded downloadable versions
Python website with embedded downloadable versions

After downloading make sure the the MD5 checksum matches. This can be accomplished using PowerShell and the Get-FileHash command.

Get-FileHash python-3.12.0-embed-amd64.zip MD5

I like to copy the sum output and use the browsers find in page function to make sure that is matches (as shown in the screenshot above).

Extract the zip file

Next extract the zip file to your preferred install location. In this case I created c:\python312 this gives a good indication of what is in the directory as well as giving all users access to it.

Extract the Python zip file to preferred location.
Extract the Python zip file to preferred location.

Add Python to the Path

After it is extracted it’s time to add it to the path so it can be used.

Add Python to the Path environment variables.
Add Python to the Path environment variables.

Be sure to add both c:\python312 and c:\python312\Scripts as the Scripts directory is where Python stores other executable files such as pip and virtualenv.

Check that Python is Working

Check that Python is available and working.
Check that Python is available and working.

Now that it has been added to the path open a new PowerShell terminal to verify that it is working.

You can check that it is on the path with the following command.

$env:Path

You can also try running Python or checking the version as in the image above.

Install PiP

Head over to pypa.io to find the get-pip.py script.

After downloading the file execute using python to install.

python.exe .\get-pip.py

You should see the following output.

Install Python PiP.
Install Python PiP.

Create a Virtual Environment

Finally navigate to your development directory and create a virtual environment.

Create a Python virtual environment.
Create a Python virtual environment.
virtualenv.exe venv

Activate it with the following command and get started on development!

.\ven\Scripts\activate