DEV Community

Andrea Grandi
Andrea Grandi

Posted on • Edited on

2

Using pyenv to install Python and create a virtual environment

A few days ago Python 3.9.0 has been released and I really wanted to test ist latest features (maybe I will do a separate post to talk about them) without messing my system with another Python version.

To manage my Python versions I've been using pyenv for a while and once configured, it's very easy to install a new Python version.

Make sure your pyenv is updated

You should have at least pyenv 1.2.21 if you want to test Python 3.9.0

In case you haven't updated it and you are using MacOS, you can do it with this command:

brew update && brew upgrade pyenv
Enter fullscreen mode Exit fullscreen mode

once installed you should see the latest version:

pyenv --version
pyenv 1.2.21
Enter fullscreen mode Exit fullscreen mode

Install Python 3.9.0

To install Python 3.9.0 you only need pyenv install 3.9.0:

pyenv install 3.9.0
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.0.tar.xz...
-> https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
    Installing Python-3.9.0...
    python-build: use readline from homebrew
    python-build: use zlib from xcode sdk
    Installed Python-3.9.0 to /Users/andrea/.pyenv/versions/3.9.0
Enter fullscreen mode Exit fullscreen mode

Set Python 3.9.0 as the local version

Now that the version you want has been installed, you need to tell pyenv you want to use it:

pyenv local 3.9.0
pyenv which python
/Users/andrea/.pyenv/versions/3.9.0/bin/python
Enter fullscreen mode Exit fullscreen mode

You can find the rest of the tutorial on my blog https://www.andreagrandi.it/posts/install-python-with-pyenv-create-virtual-environment-with-specific-python-version/

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay