1

I'm using the basic getting started example with Python, but am running into issues. Seems like it cannot find the KeenClient I installed using "pip install keen"

Code is as below

from keen.client import KeenClient

# Initialize the Keen Client.
client = KeenClient("56ddb39a96773d7e98d63392", write_key="xxxx")

# Build your event properties as a dictionary.
ticket_purchase = {
  "price" : 50.00,
  "user": {
    "id": "020939382",
    "age": 28
  },
  "artist": {
    "id": "19039",
    "name": "Tycho"
  },
  "venue": {
    "id": "A93DJ",
    "name": "The Fillmore",
    "city": "San Francisco",
    "state": "California"
  }
}
# Add your event to the "ticket_purchases" collection.
client.add_event("ticket_purchases", ticket_purchase)

and error message is as follows:

Traceback (most recent call last):
  File "/Users/wim/Dropbox/Programming/Python/keen.py", line 1, in <module>
    import KeenClient
ImportError: No module named KeenClient
[Finished in 0.0s with exit code 1]
[shell_cmd: python -u "/Users/wimw/Dropbox/Programming/Python/keen.py"]
[dir: /Users/wimw/Dropbox/Programming/Python]
[path: /usr/bin:/bin:/usr/sbin:/sbin]

I'm running on MAC, but also have this issue on Ubuntu. I installed Keen SDK with "pip install keen" as per the documentation. Any way to solve this?

wiwa1978
  • 2,317
  • 3
  • 31
  • 67

1 Answers1

4

Rename your script from keen.py to something else like keentest.py. The name of your own program shadows the keen package and that is why keen.client cannot be imported.

  • 1
    Thanks. A shame I did not think of this myself :-). FYI, I also had to rename the folder 'keen' for your suggestion to work. – wiwa1978 Mar 07 '16 at 20:06