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 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.
~$ sudo apt install python3-pip
~$ pip3 --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
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)
[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:
Virtualenv
Anaconda
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.
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.
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
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
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.