[Tutor] Help with running an API

Alan Gauld alan.gauld at btinternet.com
Sat Oct 25 20:27:09 CEST 2014


On 25/10/14 17:08, Mark Meanwell wrote:
> Hi Folks - new to python and trying to run an API. Running version
> 2.7.3. on Windows 7 machine.
>
>   Here is the scenario for the given API (FRED API in this case):
>
> easy_install Fred from C:\ - this installs to C:\site packages
>
> then I fire up the python shell and run file created for fred api:

I'm not sure what you mean by this bit? Do you mean you run the file using

python somefile.py

Or do you start the interpreter to get the >>> prompt and then
somehow execute the file? (If so how do you run it?)

Or are you using some kind of IDE such as IDLE? In which case
how do you run the file?

> from fredapi import Fred
> fred = Fred(api_key='my api key')
> data = fred.get_series('SP500')
>
> keep getting below error message:
> ImportError: cannot import name Fred

Taking it back to basics start the Python interpreter and get a >>> prompt.

Then type

 >>> import fredapi

Does that work without errors?

Also check that your Python version is compatible with your module 
version. Third party APIs are often version specific.

Finally, since Fred is not part of the standard library, you might be 
better asking on a Fred specific forum, if one exists. This list is 
mainly for the language and standard libraries. Anything beyond that 
will have less chance of a good answer.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list