Last Updated on March 27, 2023 by mishou

I. Installing Pyenv and Pyenv-virtualenv

You can install Pyenv and Pyenv-viturualenv using Install/Remove Software on Garuda Linux.

Installing Pyenv:

Add/Remove Software

Installing Pyenv-virtualenv:

II. Installing Python with Pyenv

1.Showing all the versions of Python available

Run the command in the terminal:

pyenv install --list

2.Installing the desired version of Python

Run the command in the terminal:

pyenv install 3.9.8

3.Showing all the versions of Python installed

pyenv versions

III. Creating a virtual environment with Pyenv-virtualenv

1.Creating a virtual environment and assign it to that versio

Run the command in the terminal:

pyenv virtualenv 3.9.8 PROJECTNAME

2.Creating a directory for the project

Run the command in the terminal:

mkdir PROJECTNAME && cd PROJECTNAME/

3.Assign the virtual environment as the local environment for the directory

Run the command in the termina in the directory PROJECTNAME:

pyenv local PROJECTNAME

Now the virtual environment called PROJECTNAME is actived when you are in the PROJECTNAME directory. However, if you want to activate this environment somewhere else, you will enter that directory and run the command in the terminal:

pyenv activate PROJECTNAME

4.Upgrading pip

Run the code in the terminal:

pip install --upgrade pip

5.Installing packages with pip

Let’s install Pandas using Pip. Run the code in the terminal:

pip install pandas

You can also install multiple libraries:

pip install jupyterlab matplotlib seaborn

IV. Using Jupyter Lab

Open Jupyter Lab

Run the code in the terminal:

jupyter-lab

You can learn how to use Jupyter Notebook here:

Using Jupyter Notebook in Virtual Environments for Python Data Science Projects

V. How to delete virtual environments

1.Showing the list of the existing virtual environments

Run the command in the terminal:

pyenv versions

2.Dlete a virtual environments

If you want to delete PROJECTNAME, run the following command in the terminal:

pyenv uninstall 3.9.9/envs/PROJECTNAME

If this doesn’t work, it is a sure way to remove the directory in ~/.pyenv/versions/ manually.


By mishou

Leave a Reply

Your email address will not be published. Required fields are marked *