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

cannot import name 'convert_graph' from 'owlrl' #29

Closed
ashleysommer opened this issue Mar 8, 2019 · 3 comments
Closed

cannot import name 'convert_graph' from 'owlrl' #29

ashleysommer opened this issue Mar 8, 2019 · 3 comments

Comments

@ashleysommer
Copy link
Collaborator

As reported by a pySHACL user @ChrisGithubWork in this issue: RDFLib/pySHACL#19
On windows, when pyshacl issues from owlrl import convert_graph, python tries to import it from the owlrl.py command-line script file, rather than the module named owlrl.

I don't know if that happens on all windows installations? Nobody else has reported anything similar.
Perhaps it is only an issue if the "C:\Python35\Scripts" directory is in the PYTHON_PATH?

Anyway, this will probably go away in the next release of OWL-RL because the commandline script files no longer have a .py extension (to be more compatible with Debian packaging) so in theory that would cause python to not try to import that file as a module anymore.

@ashleysommer
Copy link
Collaborator Author

@ChrisGithubWork has indicated this is an issue with their installation, not a problem with OWL-RL or pySHACL.

@edmondchuc
Copy link
Collaborator

@ashleysommer Hi Ashley, I've been trying to deploy a flask app with gunicorn and it's giving me the same error. Any ideas why? Machine is Ubuntu 18.04, Python 3.6.7.

It runs fine using the local flask server.

(venv) ubuntu@vocab-corveg-dev2:/var/www/skos_viewer$ gunicorn --bind 127.0.0.1:5000 gunicorn_app:app
[2019-04-19 03:15:54 +0000] [23070] [INFO] Starting gunicorn 19.9.0
[2019-04-19 03:15:54 +0000] [23070] [INFO] Listening at: http://127.0.0.1:5000 (23070)
[2019-04-19 03:15:54 +0000] [23070] [INFO] Using worker: sync
[2019-04-19 03:15:54 +0000] [23073] [INFO] Booting worker with pid: 23073
[2019-04-19 03:15:54 +0000] [23073] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/var/www/skos_viewer/venv/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    worker.init_process()
  File "/var/www/skos_viewer/venv/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
    self.load_wsgi()
  File "/var/www/skos_viewer/venv/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/var/www/skos_viewer/venv/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/var/www/skos_viewer/venv/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
    return self.load_wsgiapp()
  File "/var/www/skos_viewer/venv/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/var/www/skos_viewer/venv/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
    __import__(module)
  File "/var/www/skos_viewer/gunicorn_app.py", line 1, in <module>
    from app import app
  File "/var/www/skos_viewer/app.py", line 4, in <module>
    from owlrl import DeductiveClosure, OWLRL_Semantics
  File "/var/www/skos_viewer/venv/bin/owlrl.py", line 4, in <module>
    from owlrl import convert_graph, RDFXML, TURTLE, JSON, AUTO, RDFA
ImportError: cannot import name 'convert_graph'
[2019-04-19 03:15:54 +0000] [23073] [INFO] Worker exiting (pid: 23073)
[2019-04-19 03:15:54 +0000] [23070] [INFO] Shutting down: Master
[2019-04-19 03:15:54 +0000] [23070] [INFO] Reason: Worker failed to boot.

@ashleysommer
Copy link
Collaborator Author

Hi Edmond,
This is a known issue in the current released version of OWL-RL on PyPI.
It caused because Python is treating the script called owlrl.py in the venv/bin/ directory as the OWL-RL module itself, and trying to import from that.

The problem has already been fixed in master, but no new release made yet.

Two ways you can fix this now in your application:

  1. Uninstall the PyPI version and install the master branch from github, or
  2. rename the file venv/bin/owlrl.py to venv/bin/owlrl (remove the .py extension)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants