Skip to content

Quickly setup a portable python environment for Windows.

License

Notifications You must be signed in to change notification settings

jtmoon79/PythonEmbed4Win

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 

Repository files navigation

PythonEmbed4Win

PowerShell 5 PowerShell 7 Python Versions

A single PowerShell script to easily and quickly create a standalone Python local environment for Windows by downloading the requested embed.zip distributed file. No prior Python installation is required.

To run:

Invoke-WebRequest -Uri "https://raw.githubusercontent.com/jtmoon79/PythonEmbed4Win/main/PythonEmbed4Win.ps1" -OutFile "PythonEmbed4Win.ps1"
.\PythonEmbed4Win.ps1

For detailed help:

Get-Help .\PythonEmbed4Win.ps1 -full

If you get the error
PythonEmbed4Win.ps1 cannot be loaded because running scripts is disabled on this system
then run:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process

Installing the Python for Windows embedded zip file requires some tedious tweaks. See this gist. This script will handle the tedious tweaks and updates so the new Python installation will run correctly in an isolated manner.

This is similar to a Python Virtual Environment but technically is not. It does not require an activate script to set environment variable VIRTUAL_ENV or modify the PATH. It will run isolated without environment modifications.

One disadvantage is that a Windows embed Python cannot create a functioning virtual environment. They will be created but virtualenv and venv selectively copy files from the source and do not copy necessary library files unique to an Windows embed Python.

Derived from this StackOverflow answer.