Unsupported Python Install Manager use cases

After evaluating the new Python Install Manager and reviewing user feedback and problem reports, I have concerns with the responses indicating features aren’t supported, issues are attributed to external bugs, or that nothing can be done about legitimate use cases and issues with the new python install manager. This direction will create a lot of work for people that fit into the gray area of not being IT professionals but still supporting small labs or groups of systems, like in a classroom. Deploying a version of Python for system use in a controlled environment should be a supported use case. I understand that limitations of the Windows Store and msix installer may be the root cause of these issues; but regardless support should be provided for those use case in some form or as an alternative maintain the standalone installer even if it is de-emphasized on the site.

In an attempt to help those who are having issues and haven’t found a solution, I thought I would start a thread to discuss what could be a close approximation of what deploying Python in one of the unsupported use cases is going to look like. This method should work for the use cases of installing for all users, CWD being where the script is and not C:\Windows\system32, and should resolve issues with argument passing in the console. It is not without its issues, for example updating will be a completely manual process as will selecting specific Python versions to execute, and aliases and file associations will be a painful windows experience. However, if you fall in one of the now unsupported use cases; this might be an option.

Note: These need to be executed with the an admin account.

  1. Download the zip file containing binary files of the release you want
    ie. https://www.python.org/ftp/python/3.XX.Y/python-3.XX.Y-amd64.zip

  2. Extract those files to somewhere like “C:\Program Files\Python-3.XX”

  3. Add “C:\Program Files\Python-3.XX\Scripts” to the system path

  4. Add “C:\Program Files\Python-3.XX” to the system path

  5. Adjust windows file associations so they work on the command line:
    Note: These might take some adjustments to get correct when previous
    version have been installed.

@echo off

echo Removing Existing File Associations

assoc .py=Python.File
assoc .pyw=Python.NoConFile
assoc .pyw=pyw_auto_file

echo Setting New File Associations

ftype Python.File="C:\Program Files\Python-3.XX\python.exe" "%1" %\*
ftype Python.NoConFile="C:\Program Files\Python-3.XX\pythonw.exe" "%1" %\*
ftype pyw_auto_file="C:\Program Files\Python-3.XX\pythonw.exe" "%1" %\*
  1. Disable Python application aliases
@echo off
setlocal EnableExtensions EnableDelayedExpansion

set ALIASES=python.exe python3.exe pythonw.exe
set BASEKEY=Software\\Microsoft\\Windows\\CurrentVersion\\App Execution Aliases

echo Disabling aliases for existing users...
for /f "tokens=\*" %%S in ('reg query HKU ^| find "S-1-5-21"') do (
    for %%A in (%ALIASES%) do (
        echo Adding entry "%%S\\%BASEKEY%\\%%A"
        reg add "%%S\\%BASEKEY%\\%%A" /v Enabled /t REG_DWORD /d 0 /f >nul 2>&1
    )
)

echo Disabling aliases in the default profile...
reg load HKU\\DefaultUser "C:\\Users\\Default\\NTUSER.DAT" >nul 2>&1
if %ERRORLEVEL% EQU 0 (
    for %%A in (%ALIASES%) do (
        echo Adding entry "HKU\\DefaultUser\\%BASEKEY%\\%%A"
        reg add "HKU\\DefaultUser\\%BASEKEY%\\%%A" /v Enabled /t REG_DWORD /d 0 /f >nul
    )
    reg unload HKU\\DefaultUser >nul
) else (
    echo ERROR: Failed to update default User profile
)
  1. Optionally, pre-compile all libraries; Must be done after environment path
    changes have taken affect.
@echo off
cd C:\Program Files\Python-3.XX\
python.exe -m compileall .

Feel free to provide feedback or suggest improvements. There could and likely will be all sorts of issues with this.

1 Like