Will & Skill Developers

Will & Skill Developers


Thoughts, snippets and ideas from the team at Will & Skill AB, Stockholm.

Faisal Mahmud
Author

“The mind is not a vessel to be filled, but a fire to be kindled.” ― Plutarch

Share


Handle Python packages with PIP

Faisal MahmudFaisal Mahmud

Python package management has never been easier. Pip makes everything easier and works like a charm. Pip in combination with virtualenv makes Python development superfun!

If you have been maintaining Python dependencies manually in your development environment. You need to take a look at pip!

Install pip and virtualenv on Ubuntu 12.04 and newer

$ sudo apt-get install python-pip python-dev build-essential 
$ sudo pip install --upgrade pip 
$ sudo pip install --upgrade virtualenv 

NOTE: Only run pip with sudo at this point. Try not to bloat your system-wide Python env! Use virtualenv to separate depency management for your own projects.

Install the latest version of Django with pip

$ pip install django

Create a requirements.txt from your current environment

$ pip freeze > requirements.txt

Install from a requirements.txt file

$ pip install -r requirements.txt

This is awesome for deployment purposes. You do not need to handle your dependencies manually and keep track of changes, pip can do it for you!

Version specific upgrade with PIP

Imagine that You have a version specific dependency and you need to upgrade to a specific version of a package. You can use the --upgrade flag to do that. Take a look at the syntax below...

$ pip install --upgrade django==1.6.6

Read more about pip here

Happy coding!

Faisal Mahmud
Author

Faisal Mahmud

“The mind is not a vessel to be filled, but a fire to be kindled.” ― Plutarch

Comments