Virtualenv vs Virtualenvwrapper

Virtualenvis a tool to create isolated Python environments. It’s core advantage is you can manage different version of python libraries in your different projects.It works by creating a new folder on your harddisk and then copying basic python executable and libraries into it. It also add some scripts which can be used to activate the python environment. These activation scripts when executed, they change the PYTHONPATH environment variable to point the folder it recides in. This is as simple as that.You can create the virtualenv folder anywhere you like as far you execute the activation scripts provided in that folder, your current shell session will pick up the correct version of libraries.Virtualenvwrapperis a utility on top ofvirtualenvthat adds a bunch of utilities that allow the environment folders to be created at a single place, instead of spreading around everywhere.My preferred way to working aroundvirtualenvis to go the root folder of the project i’m working on, create a virtualenv folder calledvenv. You can name it anything you like as far as you stick to it.cd ~/work/myproject
virtualenv venvThis is the common name I use in every project. This gives advantage that I can add this folder in my global .gitignore file.# if you don’t have it already.
echo “venv/” >> ~/.gitignoreNow you can the following shell alias to your~/.bashrcor~/.zshrc, depending on your default shell.alias sv=”source venv/bin/activate”Now everytime you want to work on a project, that has virtualenv atvenvfolder you can run.$ sv
(venv) $(venv)before your prompt indicates that you are in the virtualenv active in that folder. To deactivate, you can run(venv) $ deactivate
$So having this setup makes me get over two cliams by virtualenvwrapper.It’s easy to activate, here I just have to typesv, after going to
project folder, which anyways I’ll be going to.Addingvenv/to your global gitignore will make sure it doesn’t get
included in git by default.This way you can avoid learning yet another tool or one less dependencies. And the best advantage is that all the source code of different libraries just lives by the side your project. In your favorite editor you can search globally for a term or defination.If you use sublime text, it’s as easy as pressingcmd + shift + fand type what you are looking for, or usecmd + pto navigate anywhere.Summarizing:We learnt how to live without virtualenv wrapperhaving python libraries installed, alongside your project helps you
search and go over code base easily

News Reporter

Leave a Reply

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