简体   繁体   中英

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! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM