Import Errors

552 views
Skip to first unread message

Ryan

unread,
Sep 11, 2009, 9:15:53 AM9/11/09
to Graphserver
Greetings,
First off, I'm new to python and so i apologize in advance if this
issue is a result of my poor python knowledge. However, I'm
receiving a bunch of import errors when running some of the scripts on
Ubuntu 9.04. I installed graphserver without issue (once i figured i
needed python-dev), and when I try to run hello_world.py I get the
following error:


ryan@home-desktop:~/graphserver/pygs/examples$ python hello_world/
hello_world.py
/usr/local/lib/python2.6/dist-packages/graphserver-0.1-py2.6.egg/
graphserver/libgraphserver.so
Traceback (most recent call last):
File "hello_world/hello_world.py", line 8, in <module>
from graphserver.core import TripHopSchedule, ServiceCalendar,
Timezone, Street, Link, State, Graph
ImportError: cannot import name TripHopSchedule

Similarly, when I attempt to run compile_graph.py I get:


ryan@home-desktop:~/graphserver/pygs$ python /home/ryan/graphserver/
apps/compile_graph/compile_graph.py link bart.gtfsdb bart.graphdb
/usr/local/lib/python2.6/dist-packages/graphserver-0.1-py2.6.egg/
graphserver/libgraphserver.so
Traceback (most recent call last):
File "/home/ryan/graphserver/apps/compile_graph/compile_graph.py",
line 3, in <module>
from graphserver.compiler.compile_graph import main
File "/usr/local/lib/python2.6/dist-packages/graphserver-0.1-
py2.6.egg/graphserver/compiler/__init__.py", line 1, in <module>
from tools import *
File "/usr/local/lib/python2.6/dist-packages/graphserver-0.1-
py2.6.egg/graphserver/compiler/tools.py", line 3, in <module>
from graphserver.ext.osm.osmdb import OSMDB
File "/usr/local/lib/python2.6/dist-packages/graphserver-0.1-
py2.6.egg/graphserver/ext/osm/osmdb.py", line 12, in <module>
from rtree import Rtree
ImportError: No module named rtree


Any assistance would be greatly appreciated. Thanks.


Brandon Martin-Anderson

unread,
Sep 11, 2009, 1:23:12 PM9/11/09
to graph...@googlegroups.com
Hey Ryan,

The import errors have two separate causes:

the hello_world.py error is caused by (as usual) depricated code hanging around in the codebase. The class TripHopSchedule has been removed, and hello_world.py is in need of an update.

As far as rtree goes - you probably don't have rtree! Information and installation here: http://pypi.python.org/pypi/Rtree/

-B

Ryan

unread,
Sep 12, 2009, 12:20:29 AM9/12/09
to Graphserver
Thanks for the pointer. Not the topic of this forum, but I'm running
into issues with Rtree. Installing spatialindex-1.4.0 creates the
libraries libspatialindex.so, libspatialindex.so.1, and
libspatialindex.so.1.0.0 but Rtree is looking for
libspatialindex_c.so. I get


...
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from rtree import core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "rtree/__init__.py", line 8, in <module>
from index import Rtree
File "rtree/index.py", line 2, in <module>
import core
File "rtree/core.py", line 94, in <module>
rt = ctypes.CDLL(lib_name)
File "/usr/lib/python2.6/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libspatialindex_c.so: cannot open shared object file: No such
file or directory





On Sep 11, 11:23 am, Brandon Martin-Anderson <badh...@gmail.com>
wrote:
> Hey Ryan,
>
> The import errors have two separate causes:
>
> the hello_world.py error is caused by (as usual) depricated code hanging
> around in the codebase. The class TripHopSchedule has been removed, and
> hello_world.py is in need of an update.
>
> As far as rtree goes - you probably don't have rtree! Information and
> installation here:http://pypi.python.org/pypi/Rtree/
>
> -B
>

Nino Walker

unread,
Sep 14, 2009, 1:28:03 PM9/14/09
to graph...@googlegroups.com
Look on the Rtree mailing list, and verify you have the right version of Rtree and spatialindex, as there's been recent changes which will create version incompatibilities.

fruminator

unread,
Oct 21, 2009, 11:33:53 PM10/21/09
to Graphserver
Nino, is this thread what you are referring to:
http://www.mail-archive.com/comm...@lists.gispython.org/msg00563.html
?

I am having basically the same error as you were:

File "/usr/local/lib/python2.6/dist-packages/Rtree-0.5.0-py2.6-linux-
x86_64.egg/rtree/core.py", line 97, in <module>
rt = ctypes.CDLL(lib_name)
File "/usr/lib/python2.6/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libsidx.so: cannot open shared object file: No such file or
directory


I guess I am confused because in that thread on the Rtree mailing list
they say they fixed it, but I just installed Rtree today and clearly
it's not fixed. I used your fix with LD_LIBRARY_PATH and it seems to
now work, but that is, as you say, not optimal.

Thanks,
Mike


On Sep 14, 1:28 pm, Nino Walker <n...@urbanmapping.com> wrote:
> Look on the Rtree mailing list, and verify you have the right version of Rtree and spatialindex, as there's been recent changes which will create version incompatibilities.
>
> -----Original Message-----
> From: graph...@googlegroups.com [mailto:graph...@googlegroups.com] On Behalf Of Ryan
> Sent: Friday, September 11, 2009 9:20 PM
> To: Graphserver
> Subject: Re: Import Errors
>
> Thanks for the pointer.  Not the topic of this forum, but I'm running
> into issues with Rtree.  Installing spatialindex-1.4.0 creates the
> librarieslibspatialindex.so,libspatialindex.so.1, andlibspatialindex.so.1.0.0 but Rtree is looking for

Nino Walker

unread,
Oct 22, 2009, 12:21:23 AM10/22/09
to graph...@googlegroups.com
They fixed it in the trunk but didn't re-release it.

Leon Stenneth

unread,
Jan 13, 2013, 9:10:50 AM1/13/13
to graph...@googlegroups.com
So what is the final solution to the fix "Import error: No module named RTree"
Reply all
Reply to author
Forward
0 new messages