6

I'm getting this error:

ImportError: Could not find the GEOS library (tried ""geos_c"", ""libgeos_c-1"").  
Try setting GEOS_LIBRARY_PATH in your settings

when I run:

from django.contrib.gis.geos import *
pnt=GEOSGeometry('POINT(23 5)')
print(pnt)

I added GEOS_LIBRARY_PATH = 'C:/Python34/Lib/site-packages/osgeo/geos_c.dll'
in C:\Python34\Lib\site-packages\django\conf\project_template\project_name\settings.py

But still Im getting the same error. How to solve this?

SiHa
  • 7,830
  • 13
  • 34
  • 43
Bruce
  • 565
  • 2
  • 8
  • 23
  • dont add it to Django settings! Add it into the settings.py in your project! You should never modify Django installation, because when you then update to newer Django it will get overwritten – mirosval Dec 17 '15 at 07:40
  • I created a project mysite in C:\Python34\Lib\site-packages\django\bin\ and added GEOS_LIBRARY_PATH = 'C:/Python34/Lib/site-packages/osgeo/geos_c.dll. in settings.py But Im getting the same error. – Bruce Dec 17 '15 at 08:52
  • Wait what? Dont create your project in site-packages, that is the place where you install 3rd party packages in Python – mirosval Dec 17 '15 at 09:04
  • please could you explain where can I create the project. I'm new to django. I want to execute from django.contrib.gis.geos import * pnt=GEOSGeometry('POINT(23 5)') print(pnt) – Bruce Dec 17 '15 at 09:16

2 Answers2

4

I don't know what is the most correct way to use with Windows, you can try to find solution here, but for ubuntu command:

sudo apt-get install binutils libproj-dev gdal-bin

solved the problem.

P.S. From dock:

The setting must be the full path to the C shared library; in other words you want to use libgeos_c.so, not libgeos.so.

Extension of the library must be *_c.so

rborodinov
  • 141
  • 1
  • 4
1

Are You sure path is correct? This is My path:

GEOS_LIBRARY_PATH = 'c:\\Program Files\\PostgreSQL\\9.1\\bin\\libgeos_c-1'

You need GEOS from PostgreSQL.

Tomasz Jakub Rup
  • 10,502
  • 7
  • 48
  • 49
  • Please could you let me know if I have to add this path in settings.py of my project? If yes, in which path should I create the project ? – Bruce Dec 17 '15 at 09:27