4 ms·
After using many different Python tools (Poetry, Pipenv, virtualenv, etc) I've found that the most reliable method is to just use the standard `venv` command to
by amanzi 7y ago
After using many different Python tools (Poetry, Pipenv, virtualenv, etc) I've found that the most reliable method is to just use the standard `venv` command to create virtual environments. I have the following `cvenv` ('create venv') alias set up in my .bashrc to create new virtual environments:
alias cvenv='python -m venv .venv && source .venv/bin/activate && pip install --upgrade pip setuptools > /dev/null'
Also, as others have mentioned, if you're not in a virtual environment, only ever install pip packages to your user location, i.e. `pip install --user --upgrade package_name`
But the first thing to do before any of that is to make sure you know which python binaries you're running:
which python
which python3
which python3.7
etc...
You can use the following command to set your default Python:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 9
(that sets python3.7 as the default when you just type `python`)