I want to help you know how to install pip – an alternative package manager for python. One interesting fact is that the process of installing pip is very similar to that of installing easy_install which I did a few days ago. I know how frustrating it can be and that is why I want to save you some time! Without much ado, let us see how to install pip, shall we?
Simple steps on how to install pip
1)You will need setuptools before moving on:
Here is why I say that you need setuptools installed and don’t worry, I will show you everything you need.
In order for you to install setuptools, you will need to use ez_setup.py . Again, I will show you next how to get it easily.
2)Download ez_setup.py and save it to your Desktop
If you click the above link, you will see a file on your browser that looks like the one below. Please select all the content and create a document on your Desktop, paste the copied content and save the file as ez_setup.py . I recommend Desktop for easy access!
I used the arrows to mean that the file is bigger than what you see in my screenshot. Just do Ctrl + A to select everything.
3)Go to your command line and change the directory to the desktop:
If you are using Windows, simply type cmd and press enter from the start menu. If you use a mac, open the terminal! Once you have changed your directory to Desktop (use cd to change directory), do the following:
Type : ez_setup.py
and press Enter. Doing that will run the file ez_setup.py and install everything you need for this step. That includes easy_install which you can find inside C:\Python27\Scripts or whichever location your Python is installed. Now move on to the next step. Almost done here.
4)Verify that easy_install is inside Scripts sub-folder
This is not necessarily a must but just to save time, go to your Python directory (where you installed Python) and open the Scripts sub-folder. Look inside it and make sure that you can see easy_install - an executable file. It looks like this for me:
As you can see, I have easy_install inside the Scripts sub-directory. If that is the same for you regardless of where your Python is installed, move to the next step.
5)Add the directory to the Path environment variable
In order to make your life really easier (being able to use easy_install on your command line easily), you need to add the above directory to your Path environment variable. Which directory, you ask? Depending on where your Python is installed, simple open the Scripts folder and then select its location. Mine from the above snapshot, would look like this: C:\Python27\Scripts - because I installed Python version 2.7 in the C directory.
Once you have selected it, move to the next step to add it to your path environment variable.
6)The Path Environment variable
Please locate your Advanced System Settings and click on Environment Variables. Then under System Variables, select Path and Click Edit. That will open a small window. Looks something like this:
Note: You can click on the image to zoom in please!
In that small window, for the variable value, type a semi-colon and paste the directory you selected from step 5 above. Again, mine would look like this: C:\Python27\Scripts. Remember to type a semi-colon BEFORE pasting the directory. DO NOT type a semi-colon after pasting. Now click OK until all windows are closed.
7)Open your command line and let the magic happen
We are almost done with how to install pip. The only thing left is to, well, install pip itself. We do that using easy_install. You might have already seen how frustrating it can be if you have no idea where to start. Anyway, open your command line and do this:
Type: easy_install pip
and hit Enter! That command will install pip for you in the right location. You can verify that you have successfully installed pip by looking inside the Scripts folder. You will see something like this:
As you can see, mine shows that pip is comfortably sitting there waiting for me to use! If yours doesn’t show, I would suggest uninstalling Python and have a clean installation then repeat this process. Now let us use pip and see it at work, I mean, what is the point of all these steps right?
8)Using pip to install packages
Open your command line and do the following; install something like Twitter or httpie:
That, will install Twitter library which I can then use for my Python applications by importing it. You can now install whatever you want using pip and even uninstall or update packages. In fact, do:
pip install virtualenv and then go search on Google what virtualenv is because you might love it!
If for some weird reason you would rather use easy_install than pip, you have that freedom – after all, we live in a free world – not! Please enjoy the rest of your day and you can always buy me candy if we ever meet.
Thank you for reading through this post and if you have any questions, or run into problems, please let me know and I will help you get up and running. Drop me some comments on what you think and share this post with your pals online using the buttons below! See ya!