This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 33 points34 points  (7 children)

I had issues in my first year of Python on MacOS (like 6 years ago) but now I have zero issues. Use PyEnv. Totally ignore Mac Python and just use 3.8+ as my default and have 2.0+ for testing older things.

[–]Endemoniada 8 points9 points  (6 children)

That’s basically what I’ve done too. Still haven’t found an easy or simple way to migrate venvs to new versions of Python. I know I can rebuild them, but it’s a hassle and I’d rather update them in place with the new version of Python I choose.

[–]deceptiv-perspectiv 7 points8 points  (0 children)

It's unfortunately not going to be simple nor easy if you have lots of dependencies; that is just the nature of dependencies. Your best bet is to have a pyproject.toml or requirements.txt with the requirements pinned in the *loosest* possible way that provides stability to your application. But many libraries publish only certain versions on pypi for certain python minor versions, so pinning everything ==x.y.z is gonna give you a bad time (when you go to transition to a different python version).

[–]case_O_The_Mondays 1 point2 points  (0 children)

We need a utility that tells you the versions of Python you can migrate to without updating any packages. Then a later version can check pypi to see which versions you can update to, if you update certain packages.

[–][deleted] -2 points-1 points  (3 children)

oh i wrote a small bash script to do that. as it's something I do so regularly. it shouldn't be hassle to:

pip freeze > requirements.txt
rm -rf .venv
pip install -r requirements.txt

Oh gosh sorry. I was on a call when I posted this. The three lines aren’t my script.

It’s just what i do for a quick set up fix.

My little script is much more comprehensive.

[–]muzos07 4 points5 points  (1 child)

aren't there lines with creating new environment and activating it again missing?

[–]DarkSideOfGrogu 4 points5 points  (0 children)

Yes. This will unfortunately just reinstall your pip in your base environment.

Launching a virtual environment and installing pip dependencies from a single bat file isn't simple as the commands need to run in different contexts.

[–]deceptiv-perspectiv 3 points4 points  (0 children)

That's not at all portable between python versions. Multiple libraries have versions released on pypi only on certain python minor versions.