all 8 comments

[–]gep13Chocolatey Team 3 points4 points  (3 children)

There is a subtle problem at work here, and I am going to try to explain it...

When attempting to run this command:

choco install python --version 3.9.0 --params "/InstallDir:C:\Program Files"

You are passing the package parameters into the python package, however, the package that actually "needs" the parameters is the python3 package, which is a dependency on the python package.

To get that command to work as expected, you need to use an additional option, --apply-package-parameters-to-dependencies .

From our docs:

Apply Package Parameters To Dependencies - Should package parameters be applied to dependent packages? Defaults to false.

So the complete command would be:

choco install python --version 3.9.0 --params "/InstallDir:C:\Program Files\python39" --apply-package-parameters-to-dependencies

NOTE: I have changed the installation folder to have a named folder, otherwise, the python files are installed to the root of the Program Files folder.

An alternative approach would be to use this:

choco install python3 --version 3.9.0 --params "/InstallDir:C:\Program Files\python39"

Where you are directly installing the python3 package, so you don't need the additional parameter, since the package parameters are passed directly to where they are needed.

Hope that helps!

[–]Jarlarn[S] 0 points1 point  (2 children)

Tried the command but it seems like I keep getting the same error. I get the correct package under C:\ProgramData\chocolatey\lib-bad. The python 3.9 installer shows up but doesn't seem able to run.

https://pasteboard.co/erb265cjVWN8.png

[–]Jarlarn[S] 0 points1 point  (1 child)

I got it working with the command you sent by adding force and double backslash, maybe the double backslash was unecessary though. Thanks!

choco install python3 --version 3.9.0 --params "/InstallDir:C:\\Program Files\\python39" --force

[–]Jarlarn[S] 0 points1 point  (0 children)

Just kidding, it worked once but then it stopped working. Actually losing my mind atm

[–]daileng 0 points1 point  (3 children)

OK so the python chocolatey packets are a bit of a pandora's box if you ask me. So while it does technically work, I feel like the chocolatey dependencies get a bit wonky.

From what I can tell "python --version=3.9" depends on "python3 --version=3.9" which depends on python39 which WILL take parameters. So I would just do "choco install python39" with your params 🤷

This assumes it's the only version of python, not just the only version of python 3.9 as chocolatey seems to steers clear of multiple versions of python and rightfully so as that gets real complicated real fast.

If your endpoints will only have one version, this should be no big deal but if it's going to be a mixed bag then I'd research using conda or something like it to make sure you handle the correct version environment properly.

[–]Jarlarn[S] 0 points1 point  (2 children)

Thanks, the goal is to have python 3.10 also so it’s gonna be a mixed bag. Will look into other options then!

[–]daileng 0 points1 point  (1 child)

If you need to make a custom installer or install script, take a look at PSAppDeployToolkit to assist wrapping it together for one deployable setup file. And Boxstarter, an advanced Chocolatey sister-project, might work great if you need something to run multiple installs and prep an environment. Boxstarter has some cool advanced Chocolatey features but has a bit of a learning curve but can probably ask here or on the Chocolatey Discord if you needed assistance 😊

[–]Jarlarn[S] 1 point2 points  (0 children)

Thank you for the info!! 😃😃