Jump to content

install and using Python packages ::: difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv, etc?


Recommended Posts

Hello dear Community, 

 

about the install and using Python packages ::: difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv, etc?

 

here some musings about how to install and using Python packages - approach - and subsequently - some questions: 


first we give an overview:


at the preliminary steps:

- virtualenv and venv: whats it good for and how to decide - a little overview:
- how to install, activate /deactivate and use the necessary Python tools and manage all that…

to start with the begining: some preliminary words:

Installing packages using pip and virtual environments


How to create a Python Virtual Environment: 
It is often useful to have one or more Python environments on the machine - where we can experiment with different combinations of packages without affecting our main installation on the machine.

Thanks to the Python Virtual Environments - we re lucky. Python supports this through virtual environments. The virtual environment is a copy of an existing version of Python with the option to inherit existing packages.
A virtual environment is also useful when we need to work on a shared system and do not have permission to install packages as we will be able to install them in the virtual environment.


since Python is used for many different purposes, and precisely how we want to manage our dependencies - it seems to be important for the development-process and for anyone who wants to have a well suited machine to manage development and testing environments for any kind of project.

well - at first glance we can say: how to setup a venv inside of the project directory. The reasons are:

1. It helps to make collaboration easier (we can just add the venv directory to our .gitignore, and anyone who pulls down the project can generate their own)
2. we then are able to replace/recreate the virtual environment without disturbing the related project files
3. The virtual environment is directly co-located with our project, which feels like a cleaner and easier to understand implementation to me for a beginner


Note: Well it is recommended to use at least python 3.7 because using the venv module to create virtual environments is recommended with python 3.7 and later. We can create a simple, lightweight, project virtual environment with python 3.3 and later using the venv module. First change to our project directory, then run the command shown:

cd ~/projects/my-python
python3 -m venv venv

 

This will create a subdirectory in

 ~/projects/my-python named venv. So we just have to give this directory  the name "venv".


It is a common convention to call the virtual environment directory "venv" when created as a subdirectory of a project. We can learn more about what is in this venv directory on our own, but what we need to know for now is that it will be where any dependencies for our project are installed, and it will be used to set path variables used by python when it is activated that allow our application to run with those dependencies. At any time, we can just remove this venv directory and recreate it, using the steps shown in the following. Remember that if we do so, we will have to reinstall any dependencies with pip install after recreating and activating the venv. We’ll look at the process of activating and deactivating a virtual environment to use it next.
 

 

here the question: What is the difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv, etc?

well to be frank, i guess that it would be the best to decice what are the actual needs: that said - i guess that this question
it depends on the situation.

what are the pros and cons putting the virtual environment
 

but what is the main difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv, etc?

Edited by dil_bert
  • dil_bert changed the title to install and using Python packages ::: difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv, etc?
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.