Member-only story
Setting Up Python Virtual Environments
A quick HowTo.
venv
is a package shipped with Python 3, which you can run usingpython3 -m venv
(although for some reason some distros separate it out into a separate distro package, such aspython3-venv
on Ubuntu/Debian). It serves the same purpose asvirtualenv
, but only has a subset of its features (see a comparison here). — source
I use it mainly for two reasons:
- it isolates the project-related libraries.
- it doesn’t access the globally installed libraries.
We can think of it as if the project would live on its own island, isolated from the rest of the world, having its own little things going on 🌴
Creating aliases
Before we move on, let’s create some aliases for convenience of use.
If you type which python
in terminal, it will print out the path for the python executable, which should be something like this /usr/local/bin/python3.
Then, open ~/.bashprofile you can type cat ~/.bashprofile
to open it directly in terminal or use any other way suitable for you. And add there the following line:
alias python=”/usr/local/bin/python3”
Basically, we created an alias python for python3, and what it will do is each time…