The easiest way install Python libraries is to use
pip are package managers for Python. From the easy_install page:
Easy Install is a python module (easy_install) bundled with setuptools that lets you automatically download, build, install, and manage Python packages.
and from the pip page:
To get easy_install you need to install Python setuptools and you are good to go. Sounds easy! However the setuptools installer assumes that you have the normal standalone Python installed which writes it’s install location to the registry, and when you run the installer it will say that it can’t find Python on the system. What the!?
If you have installed QGIS, or any other tool from the OSGeo4W install, you will see that OSGeo4W bundles its own version of Python in:
C:\OSGeo4W\apps\python27. This is the Python that is used when calling python in the OSGeo4W shell. It seems someone on the OSGeo wiki has made a bootstrapped installer for setuptools that will install setuptools and easy_install into the C:\OSGeo4W\apps\python27 folder for you.
Steps to take
- Download ez_setup.py
python ez_setup.pyin your OSGeo4W shell
To install a package with easy_install just use:
which gives you something like:
Searching for bottle
Best match: bottle 0.11.4
Running bottle-0.11.4\setup.py -q bdist_egg –dist-dir c:\users\woo\appdata\local\temp\easy_install-5b4qq6\bottle-0.11.4\egg-dist-tmp-q2yd68
zip_safe flag not set; analyzing archive contents…
bottle: module references __file__
bottle: module references __path__
Adding bottle 0.11.4 to easy-install.pth file
Installing bottle.py script to C:\OSGeo4W\apps\Python27\Scripts
Processing dependencies for bottle
Finished processing dependencies for bottle
- You should also install pip as it is a better package manager then easy_install
- Just run
Most of the time any Python packages that are needed by your OSGeo4W tools are bundled in the installer and can be downloaded using the OSGeo4W installer, however there have been cases when I wanted to install a non OSGeo4W package into my setup by using easy_install or pip. Like bottle and flask in the example above.