I am trying to setup an isolated python virtualenv to work on GIS projects on my Mac OS X. Sounds like I will need to install the GEOS, PROJ, GDAL/OGR from the kyngchaos site here http://www.kyngchaos.com/software/frameworks and not easy_install it into my virtualenv. Is that accurate?

The downloads available on kyngchaos are pkg installers and not just an egg or bdist of python modules. So, I am not very sure as to what else the installer is doing to the environment other than just copying files to /Library/Framework/geos.framework folder.

How would I go about installing a specific version of GEOS, PROJ, GDAL/OGR into my new python virtualenv? I would appreciate your help/suggestions on this issue.

| improve this question | | | | |

If each Framework of Kyngchaos is in the PATH, it is easy. Every framework has a Unix folder, with the libraries for compiling things like pyproj or geos python wherever you want, even in a private Python environment (I've never had a problem)

The only problem is that Gdal python is in the Gdal Framework. But in site-packages there a file gdal.pth

gdal.pth file:

import sys; sys.path.insert(0,'/Library/Frameworks/GDAL.framework/Versions/1.7/Python/site-packages')

if you do not want to compile it yourself, copy this file in your isolated python virtualenv

| improve this answer | | | | |
  • having installed those projects by hand, through 3rd party installers (fink/macports/whatever) and through other means I will guarantee to you that the best way is through Kynchaos! +1000 – Ragi Yaser Burhum Feb 24 '12 at 1:39
  • @Ragi Yaser Burhum – I'm beginning to agree with you! I have been trying to use Fink to install necessary dependencies to run Cartopy in Python. I'm getting: "OSError: Could not find lib geos_c or load any of its variants" even though libgeos_c.dylib is at /sw/opt/libgeos3.6.1/lib and I've added that path to .bash_profile. I don't suppose you have any pearls of wisdom based on your experiences with fink? – user1718097 May 4 '17 at 0:18
  • @use use Homebrew :) – Ragi Yaser Burhum Jun 1 '17 at 20:52
  • @RagiYaserBurhum ;-) – user1718097 Jun 2 '17 at 22:07

I make replicable Python/C/C++ GIS environments using virtualenv and zc.buildout. My ichpage https://github.com/sgillies/ichpage project is a little dated but could serve as a template for an up-to-date one (like the one I use for my Pleiades site development work and deployments). Blog post about it at http://sgillies.net/blog/856/i-can-has-python-and-gis-environments/.

| improve this answer | | | | |

Virtualenv allows you to provision a private Python environment, but does not extend to system libraries outside of the Python universe. The three packages you mentioned are all C/C++ applications at their core, so while they have interfaces for use with Python, they cannot be packaged without interacting with the C libraries (libc on up).

Because of the difficulty installing those packages from scratch, particularly on OS X, you may want to think about running a sandboxed virtual machine using something like VirtualBox and install the packages through apt on that sandboxed machine: while it is possible to do the same on OS X, it probably isn't worth the effort.

| improve this answer | | | | |
  • This is a good recommendation. I followed this approach using Fusion, not VirtualBox, but I might try Virtual Box next time. I used CentOS for the OS in the box. (Not the best OS choice due to the stable nature and older versions of Python, etc.) – DavidF Feb 22 '11 at 16:55

If you need to use OSX you can easily avoid installation complexities by installing homebrew!

After this the only commands you will need to enter are:

brew install gdal

It will automatically install also proj and geos because they are gdal dependencies.

| improve this answer | | | | |
  • 3
    I don't believe this addresses the issue of accessing gdal from within a virtualenv (I tried it and it did not work) – djq Oct 11 '14 at 15:37
  • 1
    you can use brew install gdal as long as you create your venv with the --system-site-packages flag, see my answer here gis.stackexchange.com/a/345248/155269 – 88jayto Dec 17 '19 at 19:53

I found a good blog post that provides another solution that worked in my case:


The only difference to the blog post is that I had to do is to download the correct version of GDAL that matched the kyngchaos packages. In my case I was using the GDAL framework version 1.10, so the following install was successful

source venv/bin/activate
pip install --no-install GDAL==1.10.0
cd venv/build/GDAL
python setup.py build_ext\

Then leave the GDAL directory and install without download

cd ~
pip install --no-download GDAL

UPDATE: You might have to add some env vars before calling setup.py for the compilation step to work (see this question)

export CFLAGS=-Qunused-arguments export CPPFLAGS=-Qunused-arguments
| improve this answer | | | | |

Yellowcap's answer above worked for me with some minor tweaks:

pip install --no-install is no longer an option. Instead, inside the env directory:

pip download GDAL==1.11.2 (or whichever version you want)

Unzip the downloaded directory and cd into it:

tar -zxvf GDAL-1.11.2.tar.gz
cd GDAL-1.11.2

pip install --no-download is also no longer an option. Instead stay in the GDAL directory and run:

python setup.py build
python setup.py install
| improve this answer | | | | |

NextGIS installer have isolated gdal, geos, proj, etc. and python bindings (Python 2.7) to gdal. Installation not affected on system libraries (only several environment variables in bash_profile).

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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