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

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.

Related

Problems in running Opencv with yolo : “AttributeError: module 'cv2.dnn' has no attribute 'DNN_TARGEGT_CPU"

When I try to run the following code below for object detection through yolo3 on jupyter notebook:
classfile = "coco.names"
classes = []
wht = 320
with open(classfile,"rt") as f:
classname = f.read().rstrip("\n").split("\n")
modelconfiguration = "yolov3.cfg"
modelweight = "yolov3.weights"
net = cv2.dnn.readNetFromDarknet(modelconfiguration,modelweight)
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_OPENCV)
net.setPreferableTarget(cv2.dnn.DNN_TARGEGT_CPU)
at the last row which is net.setPreferableTarget(cv2.dnn.DNN_TARGEGT_CPU) causes the error below.
AttributeError: module 'cv2.dnn' has no attribute 'DNN_TARGEGT_CPU'
I have already tried upgrading opencv but this did not resolve the issue.
I believe it is simply a typo. Try replacing that last line with:
net.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU)
The typo of course being spelling TARGET as TARGEGT
Here is a list of Opencv DNN targets: https://docs.opencv.org/master/d6/d0f/group__dnn.html#ga709af7692ba29788182cf573531b0ff5

How do I get the weather_manager in pyowm?

The following code worked without a problem before.
import pyowm
owm = pyowm.OWM(owm_api_key)
manager = owm.weather_manager()
But now it instead outputs the error AttributeError: 'OWM25' object has no attribute 'weather_manager'
Following the code recipe in the docs, it suggests that you should do the following:
from pyowm.owm import OWM
owm = OWM(owm_api_key)
manager = owm.weather_manager()
But that just gives the error: ModuleNotFoundError: No module named 'pyowm.owm'
Considering that my code worked previously, I'm guessing that it is just some update but I can't find the right way to do it.

Botometer keeps returning TypeError

I have used this function before and it worked perfectly. However, I may have accidentally changed something and it now returns the error:
TypeError: 'module' object is not callable
For the line:
bom = botometer.botometer(wait_on_ratelimit=True,rapidapi_key=rapidapi_key,**twitter_app_auth)
The full code I use is:
def bot_detector(account,lang='universal'):
consumer_secret = deleter(open('consumer_sxcrxt.txt','r').rxad(),'\n')
consumer_key = deleter(open('api.txt','r').read(),'\n')
twitter_app_auth = {'consumer_key': consumer_key,'consumer_secret': consumer_secret}
rapidapi_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
bom = botometer.botometer(wait_on_ratelimit=True,rapidapi_key=rapidapi_key,**twitter_app_auth)
result = bom.check_account(account)
score = result['cap'][lang]
return score
print(bot_detector(1.25948029617448E+018))
Notes:
'deleter' is just a way for me to remove the line separator on the files containing my api keys.
I just checked and my twitter api keys are working.
If I put botometer.Botometer as it says on the documentation, I get the error:
AttributeError: module 'botometer' has no attribute 'Botometer'
(I think they made a typo on the documentation.)
Documentation:
https://libraries.io/pypi/botometer
I named my file 'botometer.py' and thus python was looking in the wrong place.

PyGoogleVoice API Raises TypeError when trying to login

I am trying to mess with the pygooglevoice api and am trying to run the example call program on the documentation website:
from googlevoice import Voice
from googlevoice.util import input
voice = Voice()
voice.login()
outgoingNumber = input('Number to call: ')
forwardingNumber = input('Number to call from [optional]: ') or None
voice.call(outgoingNumber, forwardingNumber)
if input('Calling now... cancel?[y/N] ').lower() == 'y':
voice.cancel(outgoingNumber, forwardingNumber)
I then get the following error when voice.login() tries to execute:
File "C:\Users\<USER>\AppData\Local\Programs\Python\Python35\lib\configparser.py", line 406, in _interpolate_some
rawval = parser.get(section, option, raw=True, fallback=rest)
TypeError: get() got an unexpected keyword argument 'raw'
I am currently using Python 3.5 on a Windows 10 machine. I am also 90% sure I configured my .gvoice file properly in my user home directory. I have the email, password, and forwardingnumber all written out in that file.
Has anyone else had this issue? Am I using a deprecated API?
I found a more recent version of the library here: https://github.com/pettazz/pygooglevoice
This did fix my configparser error but I am now encountering another problem of a different nature. However my primary problem is fixed.

how to access Flickr API using Python?

I installed everything as it says on the FlickrAPI homepage but when I try to run:
import flickrapi
api_key = '1a4c975fa83048436a2086bcab7d2290'
api_password = '5e069eae20e60297'
flickrclient = flickrapi.FlickAPI(api_key, api_password)
favourites = flickrClient.favorites_getPublicList(user_id='userid')
photos = flickr.photos_search(user_id='73509078#N00', per_page='10')
sets = flickr.photosets_getList(user_id='73509078#N00')
for photo in favourites.photos[0].photo:
print photo['title']
I get this message from the command prompt:
C:\Users\Desktop>python api.py
Traceback (most recent call last):
File "api.py", line 4, in <module>
flickrclient = flickrapi.FlickAPI(api_key, api_password)
AttributeError: 'module' object has no attribute 'FlickAPI'
Any ideas?? I have tried almost everything
FlickAPI is not the same as FlickrAPI. You're missing an r.
The file C:\Users\XXXXXX\Desktop\FLICKR API\flickrapi.py is not part of the flickrapi package. Please rename it, it is masking the real library. Right now it is being imported instead of the installed package.
The flickrapi package itself consists of a directory with a __init__.py file inside of it. Printing flickrapi.__file__ should result in a path ending in flickrapi\__init__.py.
In your "flickrclient = flickrapi.FlickAPI" line, you're missing an 'r' in FlickAPI.
Also, on the next line, your *"user_id='userid'"* argument needs an actual user ID, such as '999999#N99'
Hopefully you found that & got this working a few months ago! :)

Categories