Saturday, November 24, 2018

On Virtual Environment of Python

Different meanings of "virtuality"

I had been confused with several different packages for realizing "virtual environments" of Python, before finding the following clear article.

https://medium.freecodecamp.org/manage-multiple-python-versions-and-virtual-environments-venv-pyenv-pyvenv-a29fb00c296f



In short,
  • "venv" can create multiple different environments on a single python version, so that one can have different sets of packages installed for each environment.
  • "pyenv" makes it possible for a machine to have different python versions(>=3.3) installed.

So, if one wants to have different environments with various python versions, you need "venv" and "pyenv"; Note that "venv" is included in main python bundle.

venv usages

To create a new virtual environment with "venv" just run python with options and parameters as "-m venv new_environement_path".
I found someone advocating a nice practice to name the new environment's path simply "venv" and to have it under the project directory which uses the environment.

https://qiita.com/fiftystorm36/items/b2fd47cf32c7694adc2e

To activate a virtual environment
$ source path_to_your_virtual_environement/bin/activate
To deactivate
$ deactivate



  • To see which python versions are available online(not on the local machine)
    pyenv install --list
  • To install python version 9.9.9
    peen install 9.9.9



No comments:

Post a Comment

Writing a post in Markdown in Blogger

Following articles are helpful. * [【令和最新版】Blogger で Markdown を用いて記事を書く方法](https://qiita.com/hoge_fu-ga/items/267ea5ad4f8c120eaeb8) * [Bl...