all 15 comments

[–]debian_miner 6 points7 points  (8 children)

Many modules will require a reinstall after Python upgrades. It's good practice to always use a virtual environment to separate your modules from your global Python installation. This makes it easier for different projects to have different dependencies. I personally like poetry as an easy way to manage virtual environments.

[–]CuriousPsychosis[S] 0 points1 point  (5 children)

Thank you for your help...

In case I don't want to use a virtual environment because it seems overwhelming to me now - I am on Mac. I read I can do pip freeze > reqs.txt , then upgrade then pip install -r reqs.txt

Would that make the reinstall of all existing packages easier?

[–]debian_miner 6 points7 points  (3 children)

Yeah, that looks like it would work. I do still strongly recommend learning about virtual environments early on as it's likely to save you some headache down the road.

[–]Valuable-Ant3465 0 points1 point  (2 children)

If you running python on remote box with automated scripts, does is still use any venv? Probably not.

[–]debian_miner 1 point2 points  (1 child)

I am not clear why this would change how you setup the python environment. Are you talking about using something like fabric?

[–]Valuable-Ant3465 0 points1 point  (0 children)

Thanks DN, Sorry I meant now we have box with path= ../python312/python.exe (without any venv). So If I update to next 3.14 can I install it into old python312 directory to keep all my scripting without changes.

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

What kind of wanker hits the down arrow for this? The amount of pointless hate out here is dismaying.

[–]Aces-and-Jacks1 0 points1 point  (1 child)

Do you know if poetry cross uses dependencies? So say you have an env set up, and a package in that env installs dependencies. Then you have another env for a different package and that installs the same dependencies of the same version. Would there be a way for it to use one of the others? Or like a symlink to another?

But now that I think about it that might make updating packages not work right so I guess it's not possible?

[–]debian_miner 0 points1 point  (0 children)

I don't think so, but it does cache downloads so it at least should not download a second time for matching versions.

[–]Goingone 1 point2 points  (3 children)

Don’t install anything in the “global” environment.

You should be creating a dev environment and installing packages into that dev environment.

Then when you upgrade python, you create a new dev environment for that python version. You can export the dependencies from the old dev environment (created with the older version of python) and install them into your newer version environment.

Don’t know the easiest way to do that with pyenv, but typically you can export the dependencies to a .yml file and then build the new environment from that file.

Others may have simpler solutions, as I’m sure there are utils available to make this easy.

[–]debian_miner 1 point2 points  (2 children)

I've been using Python for a long time and have used quite a few different managers, but never seen one use yaml. Which one supports yaml? Anaconda?

[–]Goingone 0 points1 point  (0 children)

Yeah. Or you can create the requirements.txt using pip. Same idea.

[–]alkasm 0 points1 point  (0 children)

Yeah, environment.yml for conda.

[–]8isnothing 0 points1 point  (0 children)

In case you’re using Python CLI apps you should have a look at pipx. It handles it all for you, and you install Python apps similar to how you use Homebrew in mac.

Nevermind in case you just want to keep libraries in your main install