How do I get the weather_manager in pyowm? - python

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.

Related

why "bson" librarye dosen't work in jupyter notebook

I'm trying to read a bson file this is my code:
import bson
with open("D:/rl env/chat_log.bson",'rb') as f:
datas = bson.decode_all(f.read())
note that "D:/rl env/chat_log.bson" is my file path.
i got below error:
AttributeError: module 'bson' has no attribute 'decode_all'
I must mention that I didn't get any error when I ran this code in google colab.
Have you tried to use the loads method
with open("D:/rl env/chat_log.bson",'r') as f:
datas = bson.loads(f.read())

TensorFlow: How to run timeline / trace? AttributeError: module 'tensorflow' has no attribute 'RunSettings'

apparently, with a recent update to tensorflow, the option of running a trace / timeline / or whatever it's called has disappeared. The following code used to create a .json file that allowed me to see a detailed timeline of the code, using Chrome:
import tensorflow as tf
from tensorflow.python.client import timeline
run_options = tf.RunOptions(trace_level=tf.RunSettings.FULL_TRACE)
run_metadata = tf.RunMetadata()
sess.run([Network.update], feed_dict = input_dict, options=run_options, run_metadata=run_metadata)
tl = timeline.Timeline(run_metadata.step_stats)
ctf = tl.generate_chrome_trace_format()
with open('trace_file.json', 'w') as f:
f.write(ctf)
However, now I'm getting the error
AttributeError: module 'tensorflow' has no attribute 'RunSettings'
Has that function been implemented in another way? I have no idea what the documentation is trying to tell me:
https://www.tensorflow.org/api_docs/python/tf/RunOptions
Class RunOptions
Defined in tensorflow/core/protobuf/config.proto.
This directs me to a github repo and I have no idea how that would be helpful.
TLDR; How do I run the timeline / tracer with the current version of tf (1.4.1)?

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.

AttributeError: module 'elasticsearch' has no attribute 'helpers'

I can't access the helpers of elasticsearch while trying to push data in bulk mode. Package installed :
pip freeze
elasticsearch==5.3.0
When in my code I try to call this method :
import elasticsearch
client = elasticsearch.Elasticsearch([config['ES']['host']],
connection_class=elasticsearch.RequestsHttpConnection,
http_auth=(config['ES']['userName'], config['ES']['password']),
port=int(config['ES']['hostPort']),
use_ssl=True,
verify_certs=False)
elasticsearch.helpers.bulk(client, body)
I got the following error :
AttributeError: module 'elasticsearch' has no attribute 'helpers'
I'm using Python 3.5.1 and I have no problem reading data from my es cluster (without the use of helpers of course)
As #Jon Clements♦ correctly said,
import elasticsearch.helpers
Is the correct way to import (therefore also the following works)
from elasticsearch.helpers import scan
Enjoy

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