I'm trying to install the pygeoprocessing package for Python 3.4 on an Ubuntu 14.04 VM. I have all the necessary versions of the required dependencies (GDAL, numpy, scipy, shapely, Cython). pygeoprocessing is successfully installed via pip. However, when I try to import it in to a python script, I am greeted with the following:

File "route.py", line 1, in <module> from pygeoprocessing import routing File "/usr/local/lib/python3.4/dist-packages/pygeoprocessing/__init__.py", line 8, in <module> import pygeoprocessing.geoprocessing as geoprocessing File "/usr/local/lib/python3.4/dist-packages/pygeoprocessing/geoprocessing.py", line 13, in <module> import exceptions ImportError: No module named 'exceptions'

I cannot remove this line in the source code because I do not have write access on the VM. exceptions is presumably an artifact of the python2 release, and doesn't exist in python3.

How do I build pygeoprocessing properly?

1 Answer 1


You can't (without modifying the code) as the exceptions module was removed in python 3. Note: the package metadata specifies Python 2 only:

Programming Language :: Python :: 2 :: Only

I suggest you raise an issue requesting a port to Python 3.

You could try downloading, modifying and building the code yourself, then installing without root to your user site directory: python3 setup.py install --user

The minimum you'll need to do is modify pygeoprocessing/geoprocessing.py and delete line 13 and change line 2177 from raise exceptions.IOError(error_message) to raise IOError(error_message) (this change won't break Python 2 as importing exceptions to raise an IOError is unnecessary). Note that you may come across other Python 2->3 porting issues which are off topic here on GIS StackExchange.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.