1

I tried to execute a program using geonames_rdf, but I cant execute it by this error:

Traceback (most recent call last):
File "geo1.py", line 13, in <module>
 import geonames.config.log
ImportError: No module named config.log

I read several posts abot ImportError and I check the path of the system and it is correct. I'm working in a VirtualBox with a fresh Ubuntu 16.04.

The imports of my program are:

import sys
import os
import os.path
import logging
import geonames.config.log
import geonames.compat
import geonames.adapters.search

I've also tried add this line:

sys.path.append('/usr/local/lib/python2.7/dist-packages/geonames/')

The command that I used to instal this package was

sudo pip install geonames_rdf
Mohammad Yusuf
  • 16,554
  • 10
  • 50
  • 78

2 Answers2

0

Try appending site-packages not dist-packages. A bit of searching it looks like dist-packages is debian specific.

sys.path.append('/usr/local/lib/python2.7/site-packages/geonames/')

Reason:

Since you're installing 3rd party python package via pip it will not go into dist-packages and python rightfully cannot find it on the path.

Reference link: What's the difference between dist-packages and site-packages?

Community
  • 1
  • 1
Kelvin
  • 1,357
  • 2
  • 11
  • 22
  • The foldersite-packages is empty, how can I install geonames there? Thank you for your help:) – Gonzalo Molina Dec 16 '16 at 17:29
  • @GonzaloMolina I would try doing a "which python" in your shell. If your are in a virtualenv the path may be different. I would navigate to the folder and visually verify that the folders are there. doing a "sudo pip install geonames" should install it for you correctly. Thats odd – Kelvin Dec 16 '16 at 21:52
  • I'm not using a virtualenv... how can I show you my folders? – Gonzalo Molina Dec 16 '16 at 23:24
0

I just tried to use geonames_rdf, but I didn't know I needed it to do a geonames search so I installed geonames first, then discovered I had to install fiona and gdal (I'm on Windows, had to install these two using prebuilt whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/). Don't know why these dependencies aren't baked into geonames.

Anyway once I then installed geonames_rdf it seemed to install into the geonames folder in c:\Python27\lib\site-packages, added at least the adapters package. In c:\Python27\lib\site-packages\geonames there is a config folder with log.py in it.