Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pypy import error #606

Closed
vasiliy-bout opened this issue Mar 14, 2016 · 2 comments · Fixed by #684
Closed

pypy import error #606

vasiliy-bout opened this issue Mar 14, 2016 · 2 comments · Fixed by #684
Labels
bug Something isn't working
Milestone

Comments

@vasiliy-bout
Copy link

I am trying to use ontospy library from pypy and get the following error when it gets to importing SPARQLStore:

>>>> import ontospy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/pypy-2.5.0-osx64/site-packages/ontospy/__init__.py", line 9, in <module>
    from .core.graph import Graph, SparqlEndpoint
  File "/usr/local/pypy-2.5.0-osx64/site-packages/ontospy/core/graph.py", line 36, in <module>
    from rdflib.plugins.stores.sparqlstore import SPARQLStore
  File "/usr/local/pypy-2.5.0-osx64/site-packages/rdflib/plugins/stores/sparqlstore.py", line 31, in <module>
    from elementtree import ElementTree
ImportError: No module named elementtree

My pypy --version gives the following output:

Python 2.7.8 (10f1b29a2bd2, Feb 02 2015, 21:22:55)
[PyPy 2.5.0 with GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)]

Here (http://lxml.de/tutorial.html) I found the tutorial with nice example of how to import ElementTree in a portable manner:

try:
  from lxml import etree
  print("running with lxml.etree")
except ImportError:
  try:
    # Python 2.5
    import xml.etree.cElementTree as etree
    print("running with cElementTree on Python 2.5+")
  except ImportError:
    try:
      # Python 2.5
      import xml.etree.ElementTree as etree
      print("running with ElementTree on Python 2.5+")
    except ImportError:
      try:
        # normal cElementTree install
        import cElementTree as etree
        print("running with cElementTree")
      except ImportError:
        try:
          # normal ElementTree install
          import elementtree.ElementTree as etree
          print("running with ElementTree")
        except ImportError:
          print("Failed to import ElementTree from any known place")

I think imports should be rewritten to be more portable.

@joernhees
Copy link
Member

how did you install ontospy and/or rdflib? which rdflib version?

import rdflib
rdflib.__version__

@vasiliy-bout
Copy link
Author

Hi, my version of rdflib is:

>>>> import rdflib
>>>> rdflib.__version__
'4.2.1'

I have installed these ontospy and rdflib using pip command from the pypy package, like this:

/usr/local/pypy-2.5.0-osx64/bin/pip install -U ontospy rdflib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants