Installing pyenv in Ubuntu

Reshu kumari
2 min readJul 25, 2021

--

We often face situations where we are working on multiple python projects and that too of different versions. So to solve this problem we use pyenv. Which lets us have different python versions for different projects.

So the steps of installation are:

Step 1: Install prerequisites according to your OS using this.

(Troubleshooting doc)

Step 2: Install pyenv from here.

(You will see a message in the end saing update ~/.bashrc and ~/.profile you can see below step)

Step 3: Configure your shell’s environment from here.

Step 4: exec $SHELL

Step 5: check pyenv version to see if you have successfully installed pyenv usng “pyenv — version”

If you got the version number Congratulations! You have successfully installed pyenv for your project :)

But If it gives you an error something like this

Then you can troubleshoot it don’t worry

You can install Homebrew and then you can install pyenv using Homebrew.

Step1: Install Homebrew from here.

You need to update the .profile file after installing you will get a message in terminal also,

Updating directly from terminal:

echo ‘eval “$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)”’ >> /home/ubuntu/.profile

Or

To update manually:

eval “$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)”

Step 2: Installing pyenv

brew update

brew install pyenv

You can check pyenv — version you will now find that pyenv is installed.

Now as you have successfully installed pyenv you can install the desired python version in your project environment.

E.g. pyenv install 3.7.10

(Note: This was to troubleshoot if your pyenv is not working but if you want you can install Homebrew first and then install pyenv)

Hope this was helpful :)

If yes, don’t forget to like it and share it to help others. Thanks for reading.

--

--

Reshu kumari
Reshu kumari

Written by Reshu kumari

|| Student | Learner | Programmer | Curious ||

No responses yet