Hi Guys !!!
Today I am going to discuss Python package manager.
What is Python Package Manager ?
Python Package Manager is a Python utility intended to simplify the tasks of locating, installing, upgrading and removing Python packages.
Pip
First, we need to talk about Pip. Pip is python’s package manager. It has come built-in to Python for quite a while now, so if you have Python, you likely have pip installed already.
Virtualenv is a package that allows you to create named “virtual environments”, where you can install pip packages in an isolated manner
If you want to specify Python interpreter of your choice, for example Python 3, it can be done using the following command:
Now after creating virtual environment, you need to activate it. Remember to activate the relevant virtual environment every time you work on the project
Once the virtual environment is activated, the name of your virtual environment will appear on left side of terminal. Below Screen shot
Now you can install dependencies related to the project in this virtual environment. For example if you are using Django 1.9 for a project
Anaconda
Today I am going to discuss Python package manager.
What is Python Package Manager ?
Python Package Manager is a Python utility intended to simplify the tasks of locating, installing, upgrading and removing Python packages.
Pip
First, we need to talk about Pip. Pip is python’s package manager. It has come built-in to Python for quite a while now, so if you have Python, you likely have pip installed already.
Pip installs packages like tensorflow and numpy, pandas and jupyter, and many more, along with their dependencies.
pip install <your_favorite_library>
So as a demo project or learning or for a small project you can use PIP. But in real world secnario if you are working on big project which required many python labiraries(battery) in that case PIP can not help much. As part of this ecosystem, there is a whole world of version numbers and dependencies.
We sometimes need to use different versions of a given library for different projects that We are working on, so We need a way to organize our groups of packages into different, isolated environments.
There are currently two popular options for taking care of managing your different pip packages:- virtualenv and
- anaconda
Virtualenv is a package that allows you to create named “virtual environments”, where you can install pip packages in an isolated manner
Example :-
you could create an environment for web development with one set of libraries, and a different environment for data science.
This way, you won’t need to have unrelated libraries interacting with each other, and it allows you to create environments dedicated to specific purposes.
Installing virtualenv
After running this command, a directory named my_name will be created. This is the directory which contains all the necessary executables to use the packages that a Python project would need. This is where Python packages will be installed$ pip install virtualenv
Test your installation:$ virtualenv --version
Using virtualenv You can create a virtualenv using the following command:$ virtualenv my_name
If you want to specify Python interpreter of your choice, for example Python 3, it can be done using the following command:
virtualenv -p /usr/bin/python3 virtualenv_name (ubuntu)
$ source virtualenv_name/bin/activate
Now you can install dependencies related to the project in this virtual environment. For example if you are using Django 1.9 for a project
(virtualenv_saurabh)$ pip install Django==1.9
Once you are done with the work, you can deactivate the virtual environment by the following command:
Now you will be back to system’s default Python installation.(virtualenv_name)$ deactivate
Anaconda
- Now, if you are primarily doing data science work, Anaconda is also a great option.
- it is a Python distribution that comes preinstalled with lots of useful python libraries for data science.
Anaconda is popular because it brings many of the tools used in data science and machine learning with just one install, so it’s great for having short and simple setup.
- Like Virtualenv, Anaconda also uses the concept of creating environments to isolate different libraries and versions.
- Anaconda also introduces its own package manager, called conda, from where you can install libraries.
For instaling Anacoda and more details of use . check below official links
Thanks
Saurabh Sharma
Happy Coding !!!
No comments:
Post a Comment