Installing Python on Windows using the embedded package (no privileges needed)
The full Python installer for Windows is an executable file that is quite often blocked by system administrators. On the python website (https://www.python.org/downloads/windows/) you can also find the Python “embedable” package which is just a simple zip file and can function as a complete Python environment in a pinch – this is how to set things up.
Enable running powershell scripts
The embedable package is just a zip file which we will expand out so it will not adjust the registry in any way. To avoid having to set up the environment variables endlessly we will need to run a (virtualenv) powershell script so this needs to be enabled:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Get the embedable package
The current release is 3.9.10 so all that is needed is:
wget https://www.python.org/ftp/python/3.9.10/python-3.9.10-embed-amd64.zip -o python-3.9.10-embed-amd64.zip
Expand-Archive python-3.9.10-embed-amd64.zip
Adjust the installation
By default the embedable package severely limits the search-path using
a _pth
file; here we disable that and also create a missing
directory (which is fine to be empty).
mv python-3.9.10-embed-amd64\python39._pth python-3.9.10-embed-amd64\python39.pth
mkdir python-3.9.10-embed-amd64\DLLs
Get get-pip
We will want to use pip to install everything else, which we can get and install by:
wget https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python-3.9.10-embed-amd64\python.exe get-pip.py
This should now be a python environment that can install arbitary packages!
Get virtualenv and setup a test environment
We can now get virtualenv and create a new environment and install
packages into it: numpy
, jupyter
etc. There is one wrinkle
after a new environment is created a file (python39.zip) needs to be
manually copied into it:
python-3.9.10-embed-amd64\python.exe -m pip install virtualenv
python-3.9.10-embed-amd64\python.exe -m virtualenv testenv
cp python-3.9.10-embed-amd64\python39.zip testenv\Scripts\
testenv\Scripts\Activate.ps1
All together
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
wget https://www.python.org/ftp/python/3.9.10/python-3.9.10-embed-amd64.zip -o python-3.9.10-embed-amd64.zip
Expand-Archive python-3.9.10-embed-amd64.zip
wget https://bootstrap.pypa.io/get-pip.py -o get-pip.py
mv python-3.9.10-embed-amd64\python39._pth python-3.9.10-embed-amd64\python39.pth
mkdir python-3.9.10-embed-amd64\DLLs
python-3.9.10-embed-amd64\python.exe get-pip.py
python-3.9.10-embed-amd64\python.exe -m pip install virtualenv
python-3.9.10-embed-amd64\python.exe -m virtualenv testenv
cp python-3.9.10-embed-amd64\python39.zip testenv\Scripts\
testenv\Scripts\Activate.ps1
Need further advice?
Need further advice on using Python within your organisation? Contact us at webs@bnikolic.co.uk – with over 20 years of continous experience with Python (since version 2.1!) we are uniquely placed to offer advice as well as complete implementations. See https://bnikolic.co.uk/2023/05/22/python-ssc