Python my workflow

My Flow

I combined two softwares using pyenv-virtualenv :

  • pyenv manages multiple versions of Python itself
  • virtualenv (Python Virtual Environments: A Primer) manages virtual environments for a specific Python version.
  • pyenv-virtualenv manages virtual environments for across varying versions of Python.

Here the way to create virtualenv

pyenv virtualenv 3.7.2 p3

To activate the environment

pyenv activate p3

To deactivate anytime

pyenv deactivate

To uninstall the virtualenv

pyenv uninstall my-virtual-env

Create a project

Now we have virtual env p3 for example. Now need to create auto activating environment for the project myproject as follows

mkdir myproject
cd muproject
pyenv local p3

Here the complete story

Fig 1 Story-w750

Python 3 use of venv

If you want to setup project with venv, then first you have to set the python version to 3 using pyenv

pyenv global 3.8.0

Then create your project

python -m venv project

To activate the environment, move to the project directory

source bin/activate

To deactivate

deactivate

Appendix pyenv

The best Python version management software I have used is pyenv. For example, if I type the command pyenv versions, the output will be similar to this in my computer.

Fig 2-w450

As shown in the following example you can set the local application specific python version. As well as you can unset. First you check the python version which is 2.7.16 which is coming with my macOs.

Fig 3-w250

Set the new version to p3 environment, and check the version, which shows the 3.7.2 version. Now you can unset back.

Fig 4-w250

As shown in the above shell command you can set the PYENV_VERSION.

Setup Python

To install a new Python version first you have to list and see what is available

pyenv install --list

Now you can install the desired version as follows

pyenv install <version>

To uninstall:

pyenv uninstall <version>

Comments

Popular posts from this blog

How To: GitHub projects in Spring Tool Suite

Spring 3 Part 7: Spring with Databases

Parse the namespace based XML using Python