andrecastro0o / ontology2smw

automating an RDF ontology import into Semantic Mediawiki
GNU General Public License v3.0
16 stars 5 forks source link

python 3.8 error / ontology import fails #33

Closed danielriedmueller closed 3 years ago

danielriedmueller commented 3 years ago

When i follow the install instructions:

git clone https://github.com/TIBHannover/ontology2smw.git
cd ontology2smw
python setup.py install

and e.g. i try to import Aeon ontology ontology2smw --format ttl --ontology https://raw.githubusercontent.com/tibonto/aeon/master/aeon.ttl

i get following output / error

`*** ontology2smw/queries/query_classes_properties.rq ***

Traceback (most recent call last):
  File "/usr/local/bin/ontology2smw", line 11, in <module>
    load_entry_point('ontology2smw==0.0.1', 'console_scripts', 'ontology2smw')()
  File "/usr/local/lib/python3.8/dist-packages/ontology2smw-0.0.1-py3.8.egg/ontology2smw/__main__.py", line 17, in main
    sparql2smwpage(
  File "/usr/local/lib/python3.8/dist-packages/ontology2smw-0.0.1-py3.8.egg/ontology2smw/functions.py", line 61, in sparql2smwpage
    for printout in query.return_printout():
  File "/usr/local/lib/python3.8/dist-packages/ontology2smw-0.0.1-py3.8.egg/ontology2smw/classes.py", line 69, in return_printout
    self.query_graph()
  File "/usr/local/lib/python3.8/dist-packages/ontology2smw-0.0.1-py3.8.egg/ontology2smw/classes.py", line 65, in query_graph
    self.printouts = self.graph.query(sparq_query)
  File "/usr/local/lib/python3.8/dist-packages/rdflib-5.0.0-py3.8.egg/rdflib/graph.py", line 1127, in query
    result = plugin.get(result, query.Result)
  File "/usr/local/lib/python3.8/dist-packages/rdflib-5.0.0-py3.8.egg/rdflib/plugin.py", line 107, in get
    return p.getClass()
  File "/usr/local/lib/python3.8/dist-packages/rdflib-5.0.0-py3.8.egg/rdflib/plugin.py", line 69, in getClass
    module = __import__(self.module_path, globals(), locals(), [""])
  File "/usr/local/lib/python3.8/dist-packages/rdflib-5.0.0-py3.8.egg/rdflib/plugins/sparql/__init__.py", line 33, in <module>
    from . import parser
  File "/usr/local/lib/python3.8/dist-packages/rdflib-5.0.0-py3.8.egg/rdflib/plugins/sparql/parser.py", line 184, in <module>
    Param('prefix', PN_PREFIX)) + Suppress(':').leaveWhitespace()
  File "/usr/local/lib/python3.8/dist-packages/rdflib-5.0.0-py3.8.egg/rdflib/plugins/sparql/parserutils.py", line 114, in __init__
    self.name = name
AttributeError: can't set attribute
`

Do you have an idea or suggestion how i could fix the problem?

andrecastro0o commented 3 years ago

hello @danielriedmueller I tried to replicate the bug with python 3.7 and all ran as expected. I will try with python3.8. From the error logs this seems like a RDFlib error. You are using the master branch, right?

danielriedmueller commented 3 years ago

yes, i checked out master branch. thank you!

i have rdflib 5.0.0 installed

On rdflib githhub page its stated:

Versions 5.x.y supports Python 2.7 and 3.4+ and is mostly backwards compatible with 4.2.2. Only bug fixes will be applied. 6.x.y is the next major release which will support Python 3.6+. (Current master branch)

so i have to downgrade python propably

danielriedmueller commented 3 years ago

got the same error with python 3.7.3

andrecastro0o commented 3 years ago

did you re-install the package in the python 3.7 environment? python setup.py install

You can try to run without installing, with:

And cut could please post here:

danielriedmueller commented 3 years ago

the mediawiki docker image comes with python 3.7 installed, so i tried it in the docker container and ran python setup.py install. Got the same result as well with installing from requirements.txt directly.

On Python 3.7 in docker container with Debian GNU/Linux 10 pip freeze output: asn1crypto==0.24.0 attrs==20.3.0 certifi==2020.11.8 chardet==3.0.4 cryptography==2.6.1 entrypoints==0.3 flake8==3.8.4 idna==2.10 importlib-metadata==3.1.0 iniconfig==1.1.1 isodate==0.6.0 Jinja2==3.0.0a1 keyring==17.1.1 keyrings.alt==3.1.1 MarkupSafe==2.0.0a1 mccabe==0.6.1 mwclient==0.10.1 oauthlib==3.1.0 ontology2smw==0.0.1 packaging==20.4 pluggy==0.13.1 py==1.9.0 pycodestyle==2.6.0 pycrypto==2.6.1 pyflakes==2.2.0 PyGObject==3.30.4 pyparsing==3.0.0b1 pytest==6.1.2 pyxdg==0.25 PyYAML==5.3.1 rdflib==5.0.0 requests==2.25.0 requests-oauthlib==1.3.0 SecretStorage==2.3.1 six==1.15.0 toml==0.10.2 urllib3==1.26.2 zipp==3.4.0

On Python 3.8 with Pop!_OS 20.10 pip freeze output: attrs==19.3.0 beautifulsoup4==4.9.1 blinker==1.4 Brlapi==0.7.0 cached-property==1.5.1 certifi==2020.4.5.1 chardet==3.0.4 chrome-gnome-shell==0.0.0 click==7.1.2 colorama==0.4.3 command-not-found==0.3 cryptography==3.0 cupshelpers==1.0 dbus-python==1.2.16 defer==1.0.6 distro==1.5.0 distro-info===0.23ubuntu1 docker==4.1.0 docker-compose==1.25.0 dockerpty==0.4.1 docopt==0.6.2 evdev==1.3.0 flake8==3.8.4 gyp==0.1 hidpidaemon==18.4.6 html5lib==1.1 httplib2==0.18.1 idna==2.10 importlib-metadata==1.6.0 iniconfig==1.1.1 isodate==0.6.0 jeepney==0.4.3 Jinja2==3.0.0a1 jsonschema==3.2.0 kernelstub==3.1.4 keyring==21.3.0 language-selector==0.1 launchpadlib==1.10.13 lazr.restfulclient==0.14.2 lazr.uri==1.0.5 louis==3.14.0 lxml==4.5.2 macaroonbakery==1.3.1 MarkupSafe==2.0.0a1 mccabe==0.6.1 more-itertools==4.2.0 mwclient==0.10.1 netifaces==0.10.4 oauthlib==3.1.0 olefile==0.46 ontology2smw==0.0.1 packaging==20.4 Pillow==7.2.0 pluggy==0.13.1 pop-transition==1.0.1 protobuf==3.12.3 py==1.9.0 pycairo==1.16.2 pycodestyle==2.6.0 pycups==2.0.1 pydbus==0.6.0 pyflakes==2.2.0 pyflatpak==0.4.0 PyGObject==3.38.0 PyJWT==1.7.1 pymacaroons==0.13.0 PyNaCl==1.4.0 pyparsing==3.0.0b1 pyRFC3339==1.1 pyrsistent==0.15.5 pytest==6.1.2 python-apt==2.1.3+ubuntu1 python-debian==0.1.37 python-xlib==0.27 pytz==2020.1 pyxdg==0.26 PyYAML==5.3.1 rdflib==5.0.0 repolib==1.5.1 repoman==1.2.2 requests==2.23.0 requests-oauthlib==1.3.0 requests-unixsocket==0.2.0 SecretStorage==3.1.2 sessioninstaller==0.0.0 setproctitle==1.1.10 simplejson==3.17.0 six==1.15.0 soupsieve==2.0.1 systemd-python==234 texttable==1.6.2 toml==0.10.2 ubuntu-advantage-tools==24.4 ubuntu-drivers-common==0.0.0 ufw==0.36 urllib3==1.25.9 wadllib==1.3.4 webencodings==0.5.1 websocket-client==0.53.0 xkit==0.0.0 zipp==1.0.0

andrecastro0o commented 3 years ago

@danielriedmueller

So it seems that the culprit is the pyparsing lib which needs to be pinned to pyparsing==2.4.7 for rdflib.plugins.sparql to not trow an error. I have been working on this issue along side on build tests on #36 which I merged to master. The tests I added show the application building without an issue in Ubuntu with python 3.6, 3.7, 3.8

If you want to uninstall:

If you want to try and report the results, it would be great help.

Thanks for bearing with this, but it was an issue that never cropped up before!

andrecastro0o commented 3 years ago

I will close the issue. @danielriedmueller let me know if you manage to run in python3.8. Cheers

danielriedmueller commented 3 years ago

Your patch worked! It runs fine on Python 3.8 now. Thank you!