TypeError: 'NoneType' object is not subscriptable

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

TypeError: 'NoneType' object is not subscriptable

Reza
Hi jiba
I have below code :

"
default_world.set_backend(filename = "pym.sqlite3")
import_umls("umls-2019AA-full.zip", terminologies = ["ICD10", "SNOMEDCT_US", "CUI"])
default_world.save()
default_world.set_backend(filename = "pym.sqlite3")
PYM = get_ontology("http://PYM/").load()
print(type(PYM))
SNOMEDCT_US = PYM["SNOMEDCT_US"]
concept = SNOMEDCT_US[186675001]      =>> line 12
print(concept)

"
my error is :
"
Traceback (most recent call last):
  File "C:/ReportClassification/OWLready2.py", line 12, in <module>
    concept = SNOMEDCT_US[186675001]
TypeError: 'NoneType' object is not subscriptable

"

Can you guide me?
thank you
Reply | Threaded
Open this post in threaded view
|

Re: TypeError: 'NoneType' object is not subscriptable

Jiba
Administrator
Hi,

The error message suggest that PYM["SNOMEDCT_US"] is None. Are you sure the UML importation worked well ? Could you send me the output of the importation, to check it, please?

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: TypeError: 'NoneType' object is not subscriptable

Reza
I run the following code :
"
from owlready2 import *
from owlready2.pymedtermino2 import *
from owlready2.pymedtermino2.umls import *

default_world.set_backend(filename = "pym.sqlite3")
import_umls("umls-2019AA-full.zip", terminologies = ["ICD10", "SNOMEDCT_US", "CUI"])
default_world.save()
# default_world.set_backend(filename = "pym.sqlite3")
PYM = get_ontology("http://PYM/").load()
SNOMEDCT_US = PYM["SNOMEDCT_US"]
concept = SNOMEDCT_US[186675001]
print(concept)

"

Its output is as follows :

"
* Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation
Breaking ORIG cycles...
Finalizing only properties and restrictions...
Finalizing CUI - ORIG mapping...
Indexing...
FTS Indexing...
Traceback (most recent call last):
  File "C:/ReportClassification/OWLready2.py", line 11, in <module>
    concept = SNOMEDCT_US[186675001]
TypeError: 'NoneType' object is not subscriptable

Process finished with exit code 1
"

On Fri, May 24, 2019 at 3:40 PM Jiba [via Owlready] <[hidden email]> wrote:
Hi,

The error message suggest that PYM["SNOMEDCT_US"] is None. Are you sure the UML importation worked well ? Could you send me the output of the importation, to check it, please?

Jiba


If you reply to this email, your message will be added to the discussion below:
http://owlready.8326.n8.nabble.com/TypeError-NoneType-object-is-not-subscriptable-tp1086p1090.html
To unsubscribe from TypeError: 'NoneType' object is not subscriptable, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: TypeError: 'NoneType' object is not subscriptable

Jiba
Administrator
Hi,

The UMLS importation do not list any parsed .RFF files, so nothing was imported.

Could you try with the development version of Owlready (on Bitbucket)?

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: TypeError: 'NoneType' object is not subscriptable

germyrinn
In reply to this post by Reza
In general, the error means that you attempted to index an object that doesn't have that functionality. You are trying to subscript an object which you think is a list or dict, but actually is None. NoneType is the type of the None object which represents a lack of value, for example, a function that does not explicitly return a value will return None. 'NoneType' object is not subscriptable is the one thrown by python when you use the square bracket notation object[key] where an object doesn't define the __getitem__ method .

Reply | Threaded
Open this post in threaded view
|

Re: TypeError: 'NoneType' object is not subscriptable

pythoncourse
In reply to this post by Reza
Visit here to know more about this topic: typeerror nonetype object is not subscriptable