Error while removing classes in owlreaddy - python

I tried removing a class from my Ontology in owlready and im having an error :
File "C:\Users\ramid\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\namespace.py", line 274, in _to_python
if o < 0: return self._parse_bnode(o)
TypeError: '<' not supported between instances of 'NoneType' and 'int'
My code is :
import os
from owlready2 import *
onto = get_ontology("test.owl").load()
classes_to_delete=[]
a1 = get_namespace("http://w3id.org/gbo#")
a2 = get_namespace("http://www.ontology-of-units-of-measure.org/resource/om-2/")
with onto:
destroy_entity(a1.component)
Im thinking of changing to owlapi because of this inconvience . But im sure there a way to fix this because owlready is known to be stable and not have such problems. So does anyone have another way to do this or a reason why there is such an error?

Related

Calling module , 'module' object is not callable

I have module with name Ioanv1:
...
person1={"temp_lags": [-21.96,-21.82,-21.89,-21.99]}
...
def ....
Now I want to replace person1 with new data in another script:
import json
import Ioanv1
person1={"temp_lags": [-21,-21,-21,-21]}
jsonToPython = Ioanv1(person1)
print(jsonToPython)
I get TypeError: 'module' object is not callable
Could you please help me.
Error message is simple and clear.
Ioanv1 is module
You are using Ioanv1(person1) which you can not.
You probably want something like: Ioanv1.person1

Why do I get AttributeError: Canvas has no attribute acroForm?

I am trying to create a PDF with an interactive form, using Reportlab. I followed several tutorials but I am always getting the same error. The line form = c.acroForm produces AttributeError: 'Canvas' object has no attribute 'acroForm'
Has anyone experienced the same problem and know how to solve it?
from reportlab.pdfgen import canvas
from reportlab.pdfbase import pdfform
c = canvas.Canvas('my_form.pdf')
form = c.acroForm
c.save()

Wolfram alpha: AttributeError: 'module' object has no attribute 'Client'

When I try to do a simple query using wolfram alpha I am getting these errors.
This is my code:
import wolframalpha
input = raw_input("Question: ")
app_id = "**************"
client = wolframalpha.Client(app_id)
res = client.query(input)
answer = next(res.results).text
print answer
The error is :
Can you help me figure this one?
I don't think that error output actually corresponds to the code that is posted because the error message refers to a method called 'Client' (capital 'C') and the code refers to a method 'client'.
The code is almost correct. Just change the lower-case 'c' in client.
import wolframalpha
input = input("Question: ")
app_id = "8UHTA8-5QGXGEJ4AT"
client = wolframalpha.Client(app_id)
res = client.query(input)
answer = next(res.results).text
print (answer)
Output:
Question: 9+5
14
The two other changes you will note in my code are there because I'm using Python 3.
I uninstalled the wolframalpha 3.0.1 version by using pip uninstall wolframalpha in command prompt and then installed an earlier version by using pip install wolframalpha==1.0.2 in the command prompt and all the errors were solved.
Your code is correct.
You are getting this error:
"Wolfram alpha: AttributeError: 'module' object has no attribute 'Client'"
because i think it is importing a file named wolframalpha i.e. in same directory you have another file with name wolframalpha(or most probably you have named this code as wolframalpha.py).Change the name to wolframalpha.py to wolframalpha1.py
Hope this will solve your error.

browser.visit object has no attribute

I am getting an Attribute error on line 8:browser.visit("https://www.facebook.com").
"AttributeError: 'NoneType' object has no attribute 'visit'"
This is my code:
browser = Browser('firefox')
browser.visit('https://www.facebook.com')
browser.find_by_id('email').fill("")
browser.find_by_id('pass').fill("")
browser.find_by_id('loginbutton').first.click()
browser.visit('')
while x != 0:
browser.find_by_css('textarea').fill('')
browser.find_by_id('u_0_1c').click()
It pulled up with a bunch of errors at first but I fixed those, I don't understand this error? If someone could maybe explain why or what is happening it would be much appreciated.
I think you need to have import the Browser package from splinter like this
from splinter import Browser
browser = Browser('firefox)
browser.visit('https://www.facebook.com')

AttributeError: 'str' object has no attribute 'getcwd'

I'm new to python. I'm trying to unzip a file in my current script directory but I can't get this work...
zip = zipfile.ZipFile(os.getcwd() + '/Sample_APE_File.zip')
zip.extractall(os.getcwd())
Error: AttributeError: 'str' object has no attribute 'getcwd'
You assigned a string value to os, it is no longer bound to the module:
os = 'some string'
Rename that to something else.

Categories