Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python 2.7 windows silent installer (.msi) - command-line option to set the path?

When installing python 2.7 on Windows using silent installer (.msi), is there a command-line option to add Python to path environment variable, like the GUI option?

Python 3.5 installer includes an option PrependPath=0 by default, but can Python 2.7 use it?

https://docs.python.org/3/using/windows.html

Looks like this issue was discussed here, but no resolution for Python 2.7?

https://bugs.python.org/issue3561

EDIT


this batch command rocks!!!

setx \M PATH "%PATH%;C:\Python\Python27;C:\Python\Python27\Scripts"

but setx will truncate the stored %PATH% string to 1024 bytes.

like image 904
denfromufa Avatar asked Dec 11 '15 01:12

denfromufa


People also ask

Where do I find MSI installation options?

The Windows Installer MSI options can be found by opening a command window (click the Windows Start button, type in cmd and press ENTER on the keyboard), and in the command window typing msiexec /? and pressing ENTER on the keyboard.

How do I install Python silently?

To completely hide the installer UI and install Python silently, pass the /quiet option. To skip past the user interaction but still display progress and errors, pass the /passive option. The /uninstall option may be passed to immediately begin removing Python - no confirmation prompt will be displayed.


2 Answers

The Python MSI installer can update the system path since 2.4. Just add ADDLOCAL=ALL to the command line. You'll have to restart your system before it propagates.

msiexec /i "python-2.7.11.amd64.msi" /passive /norestart ADDLOCAL=ALL

https://www.python.org/download/releases/2.4/msi/

like image 159
tahoar Avatar answered Sep 19 '22 22:09

tahoar


I have observed that on Windows 7 (Professional) with python 2.7.14 x64, no restart is required for Python to be added to PATH. Just start up a new command window after the install and python will be in the PATH.

You can determine whether or not a restart is required by the install by running the msi as follows:

start/wait "" msiexec /i "python-2.7.11.amd64.msi" /passive /norestart ADDLOCAL=ALL
if %errorlevel% == 3010 ( echo Success: reboot required ) else (if %errorlevel% == 0 ( echo Success ) else ( echo Installation failed with error code %errorlevel% ) )

That is, if %errorlevel% is 3010 (ERROR_SUCCESS_REBOOT_REQUIRED), then a reboot will be required. The use of start/wait causes cmd.exe to wait until the msiexec process finishes. This allows the msiexec return status to be available to cmd.exe.

BTW You may wish to include the option ALLUSERS=1 on the command line if you want the installation of Python to be available to all users on the system.

like image 28
J. Beattie Avatar answered Sep 18 '22 22:09

J. Beattie