embeddable python

Using the embeddable Python package

Depending on how you use to share Python programs it can be exhausting. Python does, however, provide an alternative: the embeddable Python package.

Download embeddable Python package

Download the embeddable Python folder from Python’s website. Not all Python 3 versions have the embeddable Python package. I will use Python 3.9.8 for this demonstration. Once downloaded unzip the folder in your desired directory.

Embeddable Python package download from Python.org

Download and install pip

The next step is to download pip, which will be used to install all other modules. Download the pip installer (get-pip.py) then place it in the embeddable Python folder.

If you would like to find out how to download get-pip using the command line then click HERE.

We will use the command prompt to install pip. Therefore, open it and navigate into the Python folder.

Navigate the command prompt into the embeddable Python folder.
Navigate in the command prompt

However, a faster way is to directly open the command prompt in the correct directory. To do this open your file explorer in the embeddable directory then type cmd in the address bar and hit enter.

With the command prompt opened in the embeddable folder type the following command:

.\python get-pip.py

The period and backslash points to the current working directory (cwd). This ensures the Python interpreter in the cwd is used, in case Python is added to your Path variable.

Install pip from the command line.
Install pip from the command line

Edit the path file

The final step is to edit the pythonXX._pth file. To do so simply go to the main folder of the embedded Python then open the file. Add Lib\site-packages just after the last line. Now you are good to go!

Add site-packages directory to the path file
Add site-packages directory to the path file

Leave a Reply