After installing geopy-0.96.2 under Python3.2.5 I get the following: "Importerror: module geopy cannot be found." when running the script below
CREATE OR REPLACE FUNCTION geopy_test() RETURNS text AS $$
from geopy.geocoders import GoogleV3
geolocator = GoogleV3()
address, (latitude, longitude) = geolocator.geocode("Kungsgatan 20 Stockholm")
return address
$$ LANGUAGE plpython3u;
SELECT geopy_test()
I spent almost a day trying to get geopy geocoding module for Python to play nice with my Postgres 9.3 installation. Here is how I solved it...
Installing Python3.2.5 for Postgresql 9.3 (Windows 8.1)
1) Install Python3.2.5 by downloading python-3.2.5.msi. 2) Go to C:\Python32\DLLs and copy the python3.dll to ....\PostgreSQL\9.3\lib and rename it to python32.dll 3) Open control panel -> Advanced system settings -> Environmental variables Find the PATH variable and if add the paths: C:\Python32;C:\Python32\Scripts 4) Open pgAdminIII and run the SQL query: CREATE EXTENSION plpython3u; 5) The following SQL query can be used to check the install:
This should produce something like:
Installing geopy for Python3.2.5 in Postgresql 9.3 (Windows 8.1)
This should now produce something like:
8) You should now be able to test geopy within postgressql
which gave me the following answer:
"Kungsgatan 20, Norrmalm, Stockholm, Sweden"
If you get an Importerror no module found be sure to check that your installation contains the paths above by running: SELECT pyversion()