Setup and Use Pyenv in Python Applications

Rmag Breaking News

Pyenv is a popular option in Python applications. Pyenv allows you to manage different versions of Python in your application and also on your system.

Pyenv does not officially support Windows but you can use WSL (Windows Subsystem for Linux).

For more information visit: pyenv repository

Installation:

You can install using Homebrew or make a manual installation:

Using Homebrew:

brew install pyenv

Manual Installation:

Download pyenv:

curl https://pyenv.run | bash

Let’s edit your bash profile:

nano .bashrc

Add these lines in the end of the document:

export PYENV_ROOT=$HOME/.pyenv”
export PATH=$PYENV_ROOT/bin:$PATH
eval $(pyenv init –path)

Creating a Virtual Environment:

pyenv virtualenv <python_version> <env_name>

Activating the Virtual Environment:

pyenv activate <env_name>

Deactivating the Virtual Environment:

pyenv deactivate

Managing Python Versions:

Pyenv allows you to manage python versions, here is a simple tutorial that you can use in your application or in your input system:

List available versions:

pyenv install -list

Install a version:

pyenv install <version>

Defining a version:

pyenv global <version> # set a global version
pyenv local <version> # set a local version

Leave a Reply

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