-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cannot import name 'db' #16
Comments
Hmmm - not sure. That's a circular package import (I'm assuming init.py is really init.py - not sure what that's not in the file path) but it works fine for me. The only thing I can think of is that I'm using python 3.5 and you're on python 3.4. Let me see if I can figure out an easy way to get an older version of python on my system and I'll try it out. |
I think is is python 3.4. I found this reference in the release notes for 3.5 which sounds like what we're seeing. I should be able to remove the circular import so it will work on python 3.4 - give me a day or so to figure out how to test it. |
Please give it a try now - I was able to use miniconda to get a python 3.4, 3.5, and 3.6 install and was able to start it up on all three now with the changes that were submitted. |
I can run insteon-mqtt manually when I am sudoing as the insteon user, and all works well. I verified the path "/opt/insteon-mqtt/bin/insteon-mqtt start /opt/insteon-mqtt/config.yaml" is correct. |
Sorry - I'm not sure what would be different between sudo'ing to the insteon user and the startup service but clearly something must be different. Is there any chance the service is running from a different directory (or using a different version of the software), has a different PYTHONPATH, or is using a different version of python? |
I think that somehow the startup service was not running the service in the virtual environment. I re-activated the venv and it got past that. ● insteon-mqtt.service - Insteon MQTT Bridge
Loaded: loaded (/etc/systemd/system/insteon-mqtt.service; disabled)
Active: failed (Result: exit-code) since Fri 2017-12-22 21:15:36 EST; 10s ago
Process: 1269 ExecStart=/opt/insteon-mqtt/bin/insteon-mqtt start /opt/insteon-mqtt/config.yaml (code=exited, status=1/FAILURE)
Main PID: 1269 (code=exited, status=1/FAILURE)
Dec 22 21:15:36 homeassist-01 insteon-mqtt[1269]: config.apply(cfg, mqtt_handler, modem)
Dec 22 21:15:36 homeassist-01 insteon-mqtt[1269]: File "/opt/insteon-mqtt/lib/python3.4/site-packages/insteon_mqtt/config.py", line 42, in apply
Dec 22 21:15:36 homeassist-01 insteon-mqtt[1269]: modem.load_config(config['insteon'])
Dec 22 21:15:36 homeassist-01 insteon-mqtt[1269]: File "/opt/insteon-mqtt/lib/python3.4/site-packages/insteon_mqtt/Modem.py", line 103, in load_config
Dec 22 21:15:36 homeassist-01 insteon-mqtt[1269]: os.makedirs(save_path)
Dec 22 21:15:36 homeassist-01 insteon-mqtt[1269]: File "/usr/lib/python3.4/os.py", line 237, in makedirs
Dec 22 21:15:36 homeassist-01 insteon-mqtt[1269]: mkdir(name, mode)
Dec 22 21:15:36 homeassist-01 insteon-mqtt[1269]: PermissionError: [Errno 13] Permission denied: 'data'
Dec 22 21:15:36 homeassist-01 systemd[1]: insteon-mqtt.service: main process exited, code=exited, status=1/FAILURE
Dec 22 21:15:36 homeassist-01 systemd[1]: Unit insteon-mqtt.service entered failed state. The crazy thing is that I cannot duplicate the behavior when running the ExecStart command: /opt/insteon-mqtt/bin/insteon-mqtt start /opt/insteon-mqtt/config.yaml I've tried running it as different users, I made /opt/insteon-mqtt/data world writable (guessing that was what the service is complaining about, since I couldn't figure it out for sure) If you can think of something I can do to diagnose this, please let me know. Running the app from the console was working so well I'd really like to see if I can move to using this to drive my insteon stuff from hass. |
It's a simple directory problem - the error is that it can't write to 'data' which is a directory name in your config.yaml file. The simplest thing to do is tell the service to switch directories first. Add this line to your .service file:
Then you can use relative paths if you want. As long as the insteon user has permissions in /opt/insteon-mqtt, it should be able create the data directory. |
Perfect! Thanks for your patience with me. |
I'm sure it's me, but I really thought I had done everything right in installing and configuring this project, using the instructions provided in auto_start.md. However, when attempting to run "insteon-mqtt start config.yaml" I am seeing:
insteon-mqtt start config.yaml
Traceback (most recent call last):
File "/opt/insteon-mqtt/bin/insteon-mqtt", line 3, in
import insteon_mqtt
File "/opt/insteon-mqtt/lib/python3.4/site-packages/insteon_mqtt/init.py", line 17, in
from . import cmd_line
File "/opt/insteon-mqtt/lib/python3.4/site-packages/insteon_mqtt/cmd_line/init.py", line 16, in
from .main import main
File "/opt/insteon-mqtt/lib/python3.4/site-packages/insteon_mqtt/cmd_line/main.py", line 11, in
from . import start
File "/opt/insteon-mqtt/lib/python3.4/site-packages/insteon_mqtt/cmd_line/start.py", line 6, in
from .. import config
File "/opt/insteon-mqtt/lib/python3.4/site-packages/insteon_mqtt/config.py", line 13, in
from . import device
File "/opt/insteon-mqtt/lib/python3.4/site-packages/insteon_mqtt/device/init.py", line 29, in
from .Base import Base
File "/opt/insteon-mqtt/lib/python3.4/site-packages/insteon_mqtt/device/Base.py", line 10, in
from .. import db
File "/opt/insteon-mqtt/lib/python3.4/site-packages/insteon_mqtt/db/init.py", line 15, in
from .Device import Device
File "/opt/insteon-mqtt/lib/python3.4/site-packages/insteon_mqtt/db/Device.py", line 11, in
from .. import handler
File "/opt/insteon-mqtt/lib/python3.4/site-packages/insteon_mqtt/handler/init.py", line 38, in
from .DeviceDbGet import DeviceDbGet
File "/opt/insteon-mqtt/lib/python3.4/site-packages/insteon_mqtt/handler/DeviceDbGet.py", line 7, in
from .. import db
ImportError: cannot import name 'db'
What in the world have I messed up here?
The text was updated successfully, but these errors were encountered: