Geckoboard Developer Community

Usage of Python geckoboard module -> client


#1

For reasons unknown I cannot do like stated in the Python API doc with Python 3:

import geckoboard
client = geckoboard.client(API_KEY)

This gives me an error:

AttributeError: module ‘geckoboard’ has no attribute ‘client’

Instead this works for me:

from geckoboard.client import Client
client = Client(API_KEY)

So is either the documentation / code example not accurate or I’m doing something wrong… but what?


#2

Hi @gitlech!

I suspect that the issue here is where the python file that is being run is stored. In my case, my code for Geckoboard lives in the same folder as the Geckoboard python client and I don’t have an issue with the import.

Is the file you’re running stored in a different place to the Geckoboard python client?

Lisa


#3

Hi @GeckoLisa!

Thanks for your reply. When running a pip install <module_name>, I’d consider it standard behaviour that the package would be installed to /<path_to_python>/…/site-packages/ which is the case when running

pip install geckoboard.py

However, I’d find it unusual to store my working scripts (Python application) in the …/site-packages/ directory. I don’t know how the majority of Python developers would handle it, but I guess they have external package libraries and application code not in the same directory.


#4

Absolutely! I’ll make sure that we add a note in our walkthrough for Python that the instructions are for code stored in the same directory as the client and that the standard import method for packages should be used if app.py is being stored elsewhere. :slight_smile: