Tuesday, 2 June 2015

pip and easy_install

both used for installing and managing python packages.

easy_install is the older one.
pip is the one to use.

-> don't get partially installed packages - pip downloads before installing
-> dont have to be installed as egg archives (similar to  a jar file in java)
-> native support for git (There are other source code control programs available)
-> better error messages and more useful output
-> pip has an uninstall command
-> pip is the future

a cool example of using pip and virtualenv (we can recreate someone else's environment for testing):-

You create a virtual environment, and set your shell to use it. 
virtualenv env
source env/bin/activate
Now all python scripts run with this shell will use this environment's packages and configuration. Now you can install a package locally to this environment without needing to install it globally on your machine.
pip install flask
Now you can dump the info about which packages are installed with
pip freeze > list-of-packages.txt
when someone else gets your code, they can setup their own virtual environment and install all the dependencies with:
pip install -r list-of-packages.txt

No comments:

Post a Comment

bash best practices

Bash best practices A few hints on bash best practice: * use #!/usr/bin/env bash .. this is more portable but you cant rely on a spe...