-1

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 : enter image description here

Can you help me figure this one?

WhatsThePoint
  • 3,395
  • 8
  • 31
  • 53

3 Answers3

0

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.

Bill Bell
  • 21,021
  • 5
  • 43
  • 58
0

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.

Prac
  • 3
  • 3
0

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.