walidazizi / rdflib

Automatically exported from code.google.com/p/rdflib
Other
0 stars 0 forks source link

ImportError: No module named term #194

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. hg clone https://code.google.com/p/rdflib/ 
2. mv rdflib/rdflib /tmp/extras
3. touch /tmp/extras/__init__.py
4. execute python from /tmp directory and execute: from extras import rdflib

What is the expected output? 
no output, just rdflib loaded

What do you see instead?
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from extras import rdflib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "extras/rdflib/__init__.py", line 64, in <module>
    from rdflib.term import URIRef, BNode, Literal, Variable
ImportError: No module named term

What version of the product are you using? On what operating system?
Using last source from hg repository on ubuntu 11.04

Please provide any additional information below.
Pending to test in other environments. I use to follow the same steps with 
previous version of rdflib (2.4) with no problem at all.
Thanks in advance. I love rdflib. 

Original issue reported on code.google.com by kaska...@gmail.com on 27 Sep 2011 at 11:17

GoogleCodeExporter commented 8 years ago
If I understand it correctly, your approach relies on Python<=2.5 behaviour in 
which relative imports were the default. In Python>=2.6 that default has been 
changed in favour of absolute imports.

I don't know of any crufty, encapsulating meta-package trick that would allow 
you to continue your strategy uninterrupted. I was able to confirm that serial 
replacement of "import rdflib.X" with "import .X" does eventually result in a 
successful import of rdflib but I wasn't able to take it any further than that.

If there are no other options available to you then the only suggestion I can 
make is that you create a separate clone of rdflib, edited to perform relative 
imports as described above (assuming that it satisfactorily executes your 
tests) and to use that clone for your testing.

Sorry I can't be of more help.

Original comment by gjhigg...@gmail.com on 29 Sep 2011 at 7:21

GoogleCodeExporter commented 8 years ago
Thanks a lot for pointing me in the right way. I hadn't noticed this change in 
Python. I've been reading PEP 328 (Absolute and Relative Imports) and it seems 
there is nothing to do. As you say Python 2.5 was the last version allowing 
relative imports. 

It's not a big problem for me to use absolute imports but I was happiest 
building my own bundles and test them in other distros or shared webservers. 

I'm not an python expert but I wish if instead:
from __future__ import absolute_import
I could use:
from __past__ import relative_import

Much appreciated.

Original comment by kaska...@gmail.com on 2 Oct 2011 at 8:31

GoogleCodeExporter commented 8 years ago
not really a bug.

Original comment by gromgull on 12 Jan 2012 at 12:40