jaraco / wolframalpha

MIT License
148 stars 26 forks source link

How to fix AttributeError: results ? #12

Closed rvslan closed 7 years ago

rvslan commented 7 years ago

This is the error

File "/opt/virtualenvs/ros/local/lib/python2.7/site-packages/wolframalpha/__init__.py", line 90, in __getattr__
raise AttributeError(name)
AttributeError: results
jaraco commented 7 years ago

I don't know. Can you dig a little deeper and troubleshoot the issue? Does that happen with all queries or just some?

rvslan commented 7 years ago

So , I fix StopIteration with try/catch but if I ask something for example Who Is Putin ? I have this error

jaraco commented 7 years ago

Sorry, but you're just not giving me enough information to help you. Here's what I did:

$ rwt wolframalpha
Collecting wolframalpha
  Downloading wolframalpha-3.0-py2.py3-none-any.whl
Collecting six (from wolframalpha)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting jaraco.itertools>=2.0 (from wolframalpha)
  Using cached jaraco.itertools-2.0.1-py2.py3-none-any.whl
Collecting xmltodict (from wolframalpha)
  Downloading xmltodict-0.11.0-py2.py3-none-any.whl
Collecting more-itertools (from jaraco.itertools>=2.0->wolframalpha)
  Using cached more_itertools-3.0.0-py3-none-any.whl
Collecting inflect (from jaraco.itertools>=2.0->wolframalpha)
  Using cached inflect-0.2.5-py2.py3-none-any.whl
Installing collected packages: six, more-itertools, inflect, jaraco.itertools, xmltodict, wolframalpha
Successfully installed inflect-0.2.5 jaraco.itertools-2.0.1 more-itertools-3.0.0 six-1.10.0 wolframalpha-3.0 xmltodict-0.11.0
Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import wolframalpha
>>> import os
>>> cl = wolframalpha.Client(os.environ['WOLFRAMALPHA_KEY'])
>>> res = cl.query('who is Putin')
>>> for pod in res.pods: print(pod)
... 
{'@title': 'Input interpretation', '@scanner': 'Identity', '@id': 'Input', '@position': '100', '@error': 'false', '@numsubpods': '1', 'subpod': {'@title': '', 'img': {'@src': 'http://www5b.wolframalpha.com/Calculate/MSP/MSP40791b9ffe5e51f6df840000102993h5gg3b143c?MSPStoreType=image/gif&s=63', '@alt': 'Vladimir Putin  (politician)', '@title': 'Vladimir Putin  (politician)', '@width': '175', '@height': '18'}, 'plaintext': 'Vladimir Putin  (politician)'}}
...
{'@title': 'Wikipedia page hits history', '@scanner': 'Data', '@id': 'PopularityPod:WikipediaStatsData', '@position': '1100', '@error': 'false', '@numsubpods': '1', 'subpod': {'@title': '', 'img': {'@src': 'http://www5b.wolframalpha.com/Calculate/MSP/MSP40921b9ffe5e51f6df84000020abdae2385abb26?MSPStoreType=image/gif&s=63', '@alt': '', '@title': '', '@width': '546', '@height': '169'}, 'plaintext': None}, 'states': {'@count': '1', 'state': {'@name': 'Log scale', '@input': 'PopularityPod:WikipediaStatsData__Log scale'}}}

The error you've reported suggests that you're calling for a results attribute on a Document. I'm not sure if that's valid usage or not. I suggest spending some more time getting to know the source code and the API. Figure out what it is you're trying to do and what you'd expect to happen. Then if what you expect to happen isn't what's happening, trace the behavior until you understand why. If that implicates a bug in the project, then report it.