How to install Python3 to custom path using Chocolatey?
Asked Answered
W

2

11

I'm installing Python 3 with Chocolatey, which installs into C:\ProgramData\chocolatey\lib\python3:

> choco install python3

Is there any way I can get Python3 to install into C:\Python35 instead?

I´m aware of this question which is related to Python 2 ... but here a different package is used thus the answer there does not help in this case.

Woodford answered 9/8, 2016 at 9:26 Comment(4)
This is pretty much a duplicate of https://mcmap.net/q/271405/-how-to-make-chocolatey-install-python2-into-custom-path/18475Complacent
@ferventcoder: As I said I am aware of it ;-) But the answer there does not work for python3 package - I have tried it.Woodford
The general idea is the same, you pass arguments through Chocolatey. Yes, the exact command arguments are different, as one would expect for different installers. It might be surprising to some that Python2 and Python3 have differences in the installers though. :)Complacent
UPDATE: > choco install python3 now installs to C:\Python35 by default.Woodford
W
12

There is a possibility to override --installargs like this:

> choco install python3 -y --override --installarguments "'/quiet  InstallAllUsers=1 TargetDir=c:\Python35'"

You might see some (access denied) errors (guess Python 3.5.1 Package is broken) but overall it seems to work.

I recommend to create your own Package as there is a newer Python version 3.5.2 which is not in the public package feed on chocolatey.org yet

Woodford answered 9/8, 2016 at 9:37 Comment(3)
Or, you could help with getting the Python package that is on the Community Feed working. The package source files are on GitHub, and we (I), would welcome any help that you could offer.Decencies
@GaryEwanPark I just followed this tutorial, I changed version 3.5.1 to 3.5.2. And in chocolateyInstall.ps1 I changed five lines: 4.$url = 'https://www.python.org/ftp/python/3.5.2/python-3.5.2.exe', 5. $url64 = 'https://www.python.org/ftp/python/3.5.2/python-3.5.2-amd64.exe', 6. $version = '3.5.2', 9. $partialInstallArgs = '/quiet /passiv InstallAllUsers=1 PrependPath=1 TargetDir=', 14. $installArgs = $($partialInstallArgs + '"' + $installPath + '"')Woodford
Sorry but the formating in comment is terrible ... can´t get it better :(Woodford
G
2

With Python 3.8.2 at least, all you can do is change the registry yourself before installing. For instance type this:

REG ADD HKLM\SOFTWARE\Python\PythonCore\3.8\InstallPath /ve /d C:/Python38 /f
Grube answered 22/4, 2020 at 11:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.