96
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 05 Jun 2024
96 points (98.0% liked)
Programming
17314 readers
244 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 1 year ago
MODERATORS
Can I request a hack? How do I handle several different versions of Python installed, which one is used for pip stuff, and how sudo/running as services changes all of this.
You can use pyenv. it will handle everything. https://github.com/pyenv/pyenv
There are like 10,000 different solutions, but I would just recommend using what's built in to python
If you have multiple versions installed you should be able to call
python3.12
to use 3.12, etcBest practice is to use a different virtual environment for every project, which is basically a copy of an existing installed python version with its own packages folder. Calling pip with the system python installs it for the entire OS. Calling it with sudo puts the packages in a separate package directory reserved for the operating system and can create conflicts and break stuff (as far as I remember, this could have changed in recent versions)
Make a virtual environment with
python3.13 -m venv venv
the 2nd one is the directory name. Instead of calling the system python, call the executable atvenv/bin/python3
If you do
source venv/bin/activate
it will temporarily replace all your bash commands to point to the executables in your venv instead of the system python install (for pip, etc).deactivate
to revert. IDEs should detect the virtual environment in your project folder and automatically activate itI started using hatch lately and really like how I can manage everything from the pyproject.toml file
https://github.com/pypa/hatch
https://github.com/jdx/mise