Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to follow a tutorial from here http://qgistips.spatialthoughts.com/2012/12/find-neighbor-polygons-in-layer-in-qgis.html#more

I have downloaded the relevant python script and edited it as required. When I try to run the script using the Python console in QGIS >Plugins>Python Console I get the following error message.

ImportError: No module named shapely.wkb Start of relevant script

from PyQt4.QtCore import *
from shapely.wkb import loads
# Replace the below value with the field containing name or id of the feature
# For example, if your field is called name then change the line below to
# name_filed = 'name'

The module shapely.wkb is called on the second line of the script so the failure appears to be occurring as the second line of code is executed.

I have searched for a Python module with that name in Plugins>Fetch Python Modules Is this something that needs to be installed separately? From what I have read it should be installed with an installation of PostGis which I though got loaded when I used StackBuilder to install PostGreSQL.

Would installing installing Python 2.7.3 on my MAC Book Pro help?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You probably missed the step where you installed shapely. Aptitude (sudo apt-get install reference) is not compatible on Mac for many reasons, none I of which I will get into.

This Shapely For MAC

should get you there.

Also, I suspect you already have a version for python on your MAC, but it might be old. Shapely requires version 2.5 and you might be under it.

Install Python For MAC

will tell you how to test your version and how to upgrade.

share|improve this answer
    
Thank you. I'll try your suggestions. –  Nigel Law Jan 20 '13 at 16:28

If you use QGIS, you have Python 2.6 (Snow Leopard) or Python 2.7 (Lion,Mountain Lion) preinstalled (like in Linux) and it is theses versions that QGIS uses, not another one (no need to install other version of Python).The pythonic way to install a Python module like shapely is not with aptitude but with the solution of Paul Smith (Shapely For MAC) see also How to install shapely for python 2.6 (Mac) NOT 2.7?

share|improve this answer
    
I am running OSx Mountain Lion v 10.8.2 so if Python comes ready installed I don't understand why I have a problem ! –  Nigel Law Jan 20 '13 at 18:36
    
because you must install shapely which is a pure Python module (in /Library/Python/2.7/site-packages/) and not a QGIS extension. –  gene Jan 20 '13 at 19:16
    
Thank you, that makes more sense. I dont have this problem on a Wndows installation :) –  Nigel Law Jan 20 '13 at 19:35
    
because the Windows version of QGIS installs its own Python while in Mac OS X or Linux (which are Unix) QGIS use the default python installed with the OS. –  gene Jan 20 '13 at 20:04
    
I must be missing something @gene. If QGIS uses the default python installed with the MAC OS why my problem? Or is it that QGIS doesn't know where to find the default python install in the MAC OS? –  Nigel Law Jan 20 '13 at 20:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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