How to Run Different Versions of Python From Your Terminal.
Version specific virtual environments. The elegant solution to needing different Python versions for different projects.
In order to install the package I required, I needed to switch to an older version of Python, but only for that project. Here is the simple solution: Version specific virtual environments.
As of writing this, I am using the latest version of Python on my machine: 3.8.5. It is usually fine to use the latest version. Except every now and then, something juicy requires an earlier version of Python for it to work, or in some cases, it won’t even install without that older version.
In this case, I’m talking about Kivy. It’s a super slick front end app development library for Python. It lets you develop mobile apps for your device completely in Python, and it’s really solid from what I can see (it even supports Material Design). But for you, it could be anything that doesn’t have support for your version of Python. Here’s a really simple and elegant way to get your specific version up and running.
- Install it on your system. Ok, you can’t use a specific version if it doesn’t exist on your system. So install the specific Python version you need. In this case, it was Python 3.7 and I already had it on my machine.
- Next, find or create a symlink to it. When you type
pythonin terminal, presstabbefore you press enter to see what you have available. You’ll see the symlinks (like shortcuts) to the different versions of Python that you have already. - If you see your
pythonversion in the list, skip to step 6. If not, you need to find out where it’s installed. - I had a version of Python 3.7 installed in
/usr/bin/python3. (I figured this out from VSCode, when I went to change my python interpreter by selecting this little button here, it showed me the path).

5. So I created a symlink to it using the command:
ln -s /usr/bin/python3 /usr/local/bin/python37Why did I need a symlink? For starters, a symlink lets me run Python 3.7 any time I want by typing in python37, but secondly, I wanted to be able to easily use it in my virtual environment.
If you don’t know about virtual environments, check my article on what they are and how to easily create one.
6. Now that I had my symlink, I simply navigated to my project folder that needed python python 3.7, and created my virtual environment, except this time, with the -p tag which allowed me to specify my python version for anything in this venv instance. Type:
virtualenv venv -p python377. Next, you want to activate your new virtual environment so, make sure you’re in the parent folder and type:
# For Unix/Linux based, type:
source venv/bin/activate# For Windows, type:
. venv/Scripts/activate8. Now type python --version to check if it worked. While you’re inside your virtual environment, you can type python, rather than your new symlink python37, because it is your primary version for all projects in this environment.
9. From this point, I was able to install Kivy without getting any weird errors, and everything worked great.
That’s it!
Hopefully this helps you if you ever need to specify a particular version of Python for a project. Answer forums are great, but sometimes it can become a real treasure hunt trying to find the right answers.
Happy coding!
Helpful tips
- If you want to exit your virtual environment, just type the word
deactivate. - If your desired symlink already exists, type
unlink <symlink path>and it will free it up for you.






