Best Python package manager and package for virtual environment ?

Author: neptune | 15th-Apr-2022 | Views: 896
#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
How to extract Speech from Video using Python?
Author: neptune | 01st-Dec-2022 | Views: 3402
#Python
Simple and easy way to convert video into audio then text using Google Speech Recognition API...

How to download video from youtube using python module ?
Author: neptune | 22nd-May-2022 | Views: 2061
#Python
We will let you know how you can easily download the Youtube high quality videos along with subtitle, thumbnail, description using python package..

Mostly asked Python Interview Questions - 2022.
Author: neptune | 25th-May-2022 | Views: 1161
#Python #Interview
Python interview questions for freshers. These questions asked in 2022 Python interviews...

How to reverse string in Python ?
Author: neptune | 16th-May-2022 | Views: 1037
#Python
We are going to explore different ways to reverse string in Python...

Python Built-in functions lambda, map, filter, reduce.
Author: neptune | 22nd-May-2022 | Views: 951
#Python
We are going to explore in deep some important Python build-in functions lambda, map, filter and reduce with examples...

Deploy Django project on AWS with Apache2 and mod_wsgi module.
Author: neptune | 22nd-May-2022 | Views: 872
#Python #Django
In this blog I use the AWS Ubuntu 18.22 instance as Hosting platform and used Apache2 server with mod_wsgi for configurations. We create a django sample project then configure server...

Will, AI kills Developer's jobs?
Author: neptune | 22nd-May-2022 | Views: 691
#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...

Core Python Syllabus for Interviews
Author: neptune | 11th-Jun-2022 | Views: 680
#Python #Interview
STRING MANIPULATION : Introduction to Python String, Accessing Individual Elements, String Operators, String Slices, String Functions and Methods...

Do you know Jupyter is now full-fledged IDE?
Author: neptune | 15th-Apr-2022 | Views: 638
#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..

Getting started with Jupyter Notebook | Python
Author: neptune | 28th-Aug-2022 | Views: 490
#Jupyter #Pip
To get started, you must open up your terminal and go to a folder of your choice. If you are using it for the first time, you need to install the Jupyter Notebook...

Datatypes in Python.
Author: neptune | 22nd-May-2022 | Views: 408
#Python
Python have different types of datatypes like Numbers, Strings, Lists, Tuples, Dictionary, Set, Frozenset, Bool, Mutable, and Immutable...

View More