Share

Best Python package manager and package for virtual environment ?

Author: neptune | 29th-May-2021 | views: 184
#Python #Anaconda #Virtualenv #Pip

In this article, I am going to tell you which package manager you should use for your python evironments either for web development or machine learning.

Everyone has different preferences when it comes to their programming environment like Virtualenv versus Anaconda. We will help you choose a better environment for you.

Pip

Pip is a python package manager it is now inbuilt with Python latest versions, If you have python then likely you have pip preinstall else follow the following command to install pip.

Commands to install pip.

For Ubuntu users.

~$ sudo apt install python3-pip

~$ pip3 --version

pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)


For Windows users.

Download this file: get-pip.py then open cmd prompt and run the command.

~$ python get-pip.py


Note: For Ubuntu users (pip3) and For Windows users (pip)

Check help option

[email protected]:~$ pip3 help


Usage:   

  pip3 [options]


Commands:

  install                     Install packages.

  download                    Download packages.

  uninstall                   Uninstall packages.

  freeze                      Output installed packages in requirements format.

  list                        List installed packages.

  show                        Show information about installed packages.

  wheel                       Build wheels from your requirements.

  debug                       Show information useful for debugging.

  help                        Show help for commands.

  many more...


Pip installs packages like NumPy, pandas, Jupiter, Django, TensorFlow and many more with their dependencies use below command to install packages.

~$ pip install library_or_package_name

Definitely, you have seen a file name requirements.txt in projects. It includes all the libraries that project uses using pip you can install all of them in one command.

~$ pip install -r requirements.txt


We need a separate virtual environment so that we can use the package manager to install packages in that isolated environment.

To take caring of this we have two different pip packages:

  1. Virtualenv

  2. Anaconda

Virtualenv

Virtualenv is a package that will help you to create an isolated virtual environment for your project or web development or Machine learning libraries.

Let's say you are working on a web development project and at the same time you also working on the Machine Learning project. For web development, you need different packages and libraries and for your Machine learning project, you need different libraries. Virtualenv will help you manage both projects in a virtual isolated environments.

For that you need to install Virtualenv in your system. Follow the bellow commands.

There is a little difference for ubuntu and windows users.

For Ubuntu users.

Installing virtualenv

~$ pip3 install virtualenv

create a virtual environment with name venv

~$ virtualenv venv

If you want to create a virtual environment for python2.7 then specify the version of python as shown below.

~$ virtualenv -p /usr/bin/python2.7 venv

Now the time is to activate a virtual environment using the below cmd where venv is the name of your environment.

~$ source venv/bin/activate

You can also use Anaconda for creating a virtual environment.

Anaconda

For data science work anaconda is a great choice. Anaconda is created by Continuum Analytics, it is python distribution that comes with preinstalled data science libraries.

Anaconda comes with tools for data science and machine learning in one install. You can install Anaconda using pip and from official site anaconda.com conda is it package manager it will install packages and libraries.

~$ pip3 install conda

Collecting conda

  Downloading conda-4.3.16.tar.gz (299 kB)

     |███████████████████████████████▊| 296 kB 83 kB/s eta 0:00:01


So the questionaries which one you use, anaconda or Virtualenv ?. We will help you decide, actually it depends on if you are working on a project related to data science or machine learning then You should choose anaconda else virtualenv.

Still confused then meet Pyenv

Pyenv

It sits on top of both anaconda and virtualenv. Pyenv lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.

You will enjoy it whenever you enter your project directory then it will activate the environment automatically.

~$ cd myproject

~$ (env)/myproject


Wrap Up things

Certainely there are a lot of tools out there it's important to remember that everyone has different needs and preferences. So you must choose for yourself which one serves you better. As per my advice, if you are working on web development then go for Virtualenv else if you are working on data science-related project then go for Anaconda.






Related Blogs
Python 3.9 new amazing features ?
Author: neptune | 25th-May-2021 | views: 213
#Python
Some of the best new feature of Python 3.9 like Dict union, Type hinting with examples..
Python Built-in functions lambda, map, filter, reduce.
Author: neptune | 26th-May-2021 | views: 199
#Python
We are going to explore in deep some important Python build-in functions lambda,map,filter and reduce with examples..
How to extract Speech from Video using Python?
Author: neptune | 25th-May-2021 | views: 191
#Python
Simple and easy way to convert video into audio then text using Google Speech Recognition API..
Will, AI kills developers and programmers job ?
Author: neptune | 05th-Jun-2021 | views: 163
#Python #Machine learning #AI
GPT-3’s performance has convinced that Artificial intelligence is closer or at least AI-generated code is closer than we think. It generates imaginative, insightful, deep, and even excellent content...
What exactly you can do with Python?
Author: neptune | 29th-May-2021 | views: 123
#Python
Well, it's a tricky question to answer because there are lots of application of Python. But, I will tell you about 3 main applications of Python...
How to download video from youtube using python module ?
Author: neptune | 26th-May-2021 | views: 121
#Python
We will let you know how you can easily download the Youtube high quality videos along with subtitle, thumbnail, description using python package..
Do you know Jupyter is now full-fledged IDE?
Author: neptune | 25th-May-2021 | views: 111
#Python #Jupyter
Jupyter is a widely used tool by Data scientists. So developers from institutions like Two Sigma, Bloomberg and fast.ai convert it into IDE lets see..
Mostly asked Python Interview Questions - 2021.
Author: neptune | 30th-Sep-2021 | views: 93
#Python #Interview
Python interview questions for freshers. These questions asked in 2021 Python interviews...
How to reverse string in Python ?
Author: neptune | 19th-Sep-2021 | views: 44
#Python
We are going to explore different ways to reverse string in Python...
View More