2

As mentioned in the title, I have updated "Python" and "pip" to their last versions, also successfully installed the "owlready2" library, but when using it in the code below:

 from owlready2 import *
 onto_path.append("path to onto in my local windows system- not linux")
 onto= get_ontology("nif.owl")
 onto.load()

Python gives me the below error:

Blockquote ModuleNotFoundError: No module named owlready2

RFAI
  • 459
  • 4
  • 17
  • please also provide a code snippet – Amartya Gaur Jun 18 '19 at 11:53
  • How did you install via pip? pip install Owlready2 – smitty_werbenjagermanjensen Jun 18 '19 at 11:58
  • @AmartyaGaur Provided as an edit, but don't know if it matters or not. – RFAI Jun 18 '19 at 12:03
  • @JoeA Yes. That's how I did it. – RFAI Jun 18 '19 at 12:03
  • 2
    I just tried it on my system which runs python 3.6 and it works when I do pip3 install Owlready2 and then run the import statement ? So maybe you're using python3 so try pip3 and then give it a go? – smitty_werbenjagermanjensen Jun 18 '19 at 12:07
  • 1
    @JoeA Thanks. I'll do it right now. – RFAI Jun 18 '19 at 12:08
  • did pip3 work for you ? @RFNO – Amartya Gaur Jun 18 '19 at 12:09
  • 1
    Sounds good let me know what happens! – smitty_werbenjagermanjensen Jun 18 '19 at 12:09
  • @JoeA It doesn't let me do a new install! Says "Requirement already satisfied" Do you think I should remove Python, pip or owlready2 and go for a fresh install? I can check it on a remote computer (Ubuntu based) too. But those usually make more problems because of permissions! – RFAI Jun 18 '19 at 12:13
  • 1
    In order to uninstall the package pip uninstall so pip uninstall owlready2 . No need to remove pip. I would just uninstall the package as stated pip uninstall owlready 2 and then use pip3 to install it – smitty_werbenjagermanjensen Jun 18 '19 at 12:15
  • 1
    @JoeA Thanks a lot! I'll do it and let you know. – RFAI Jun 18 '19 at 12:17
  • 1
    Sounds good I'll be here ! – smitty_werbenjagermanjensen Jun 18 '19 at 12:18
  • @JoeA It didn't work either! Maybe there is a problem with the path? I was looking at this: (https://stackoverflow.com/questions/14295680/unable-to-import-a-module-that-is-definitely-installed) However, it doesn't seem to be related to my problem! I also tried installing it on the remote Ubuntu system, but there was a problem there too (albeit different problem)! – RFAI Jun 18 '19 at 12:28
  • 1
    Hmmmm that's odd did you run it as python3 and not python? What's the output of pip3 list (feel free to edit the question to put the output there)? Also based on your link perhaps it's a permission issue i'm not to sure you can try that – smitty_werbenjagermanjensen Jun 18 '19 at 12:34
  • @JoeA Aha! That might be the problem! Because I usually use Java and used Python just for this project. Maybe I am not using the Python 3! How should I make sure I am using Python 3 in windows? Of course, I'll search it myself right now. – RFAI Jun 18 '19 at 12:44
  • 1
    Hmm that could be it maybe! Yeah try and use python3 well hopefully it's installed on your computer and you can just add it to your environment variable path. – smitty_werbenjagermanjensen Jun 18 '19 at 12:48
  • 1
    @JoeA Thank you for being concerned :) No luck yet! I changed to using Blazegraph but no problem there either probably because of the large size of the ontology (400Mb). The other thing is that I asked a friend who is an expert on SPARQL and he mentioned rdflib works with owlready2 if no reasoning is required! – RFAI Jun 20 '19 at 14:14

1 Answers1

-1

Restart the kernel (python), it works for me in jupyter notebook Anaconda3

owlready2 in jupyter notebook

in:
from owlready2 import *
onto = get_ontology("swo-inferred.owl").load()
onto.classes()

out:
<generator object _GraphManager.classes at 0x0000020371A9A848>
Syauqi Haris
  • 406
  • 5
  • 6