scottbonline / sense

Sense Energy Monitor API
MIT License
174 stars 45 forks source link

ModuleNotFoundError: No module named '__main__.sense_exceptions'; '__main__' is not a package #27

Closed Blackcell closed 5 years ago

Blackcell commented 5 years ago

I'm relatively new to Python. I've only written a small py to read temp from a sensor I built on a Raspberry Pi.

I want to explore your Sense API because it looks promising. I am running into this issue.

Traceback (most recent call last):
  File "sense_api.py", line 8, in <module>
    from .sense_exceptions import *
ModuleNotFoundError: No module named '__main__.sense_exceptions'; '__main__' is not a package

I am confident this is nothing to do with the code, but my environment setup and config. I wanted to document as an issue here for any behind me to find assistance if experiencing the same issue.

I'm running Windows 10, Python 3.7.2 and pip 19.0.2.

Thanks.

kbickar commented 5 years ago

What's your code look like?

The ideal way to run it would be: from sense_energy import Senseable or import sense_energy

Blackcell commented 5 years ago

Just trying to tinker with it I ran sense_api.py. I haven't imported it into any code yet.

kbickar commented 5 years ago

Ah running it directly probably won't work. Maybe we can include some test files

Blackcell commented 5 years ago

The example usage on the README probably needs to be updated as well. I'm writing something to import it(success) and attempting to figure out how to instantiate it. This is just a python growing pain, though.

Edit: I got it. If you guys want, I can help update the documentation? Just let me know, @kbickar.

kbickar commented 5 years ago

Sure submit a PR.

FYI, here's a small test I've used:

from sense_energy import Senseable
username = "user"
password = "pass"
sense = Senseable(wss_timeout=2)
sense.authenticate(username, password)
sense.get_realtime()
print ("Active:",sense.active_power,"W")