I was able to get python to see the AutomationHat Library by setting the virtualenv to use external package (virtualenv --system-site-packages venv),
I have a new error saying I either dont have permission or can’t find SMBUS (“This library requires python-smbus\nInstall with: sudo apt install python-smbus”)
It’s got to be a permissions thing, because if I run it using Sudo, I can actually run it. The problem is I don’t know how to run uWSGI as sudo and I’m not sure I want it to require root priviledges to run… Thoughts?
I have an odd one here.
I think it’s one of two possibilities, but I’m not sure what the fix might be.
- I have a RaspberryPiZero W
- I have the AuthomationPhat attached
- I developed an application that works 100% fine under the Pi user, and no VirtualEnv.
- I used the curl command, from the installation instruction, to install the library.
- Here, I CAN load the library in both python command line, and in a .py file, without any issue.
- The app is then hosted in Flask. It recognizes hardware IO changes just fine, and displays it to the website.
- Now that I have the prototype ready, I am setting up the Pi for a “Production” scenario.
- I created a new User on the same Pi, with tighter privileges restrictions (Firewall, Read/Write, etc.) , but still has Sudo privileges for now while I set it up.
- I created a new Python Virtual Environment to containerize the project. (this part was new to me, I assume I did it correctly)
Here is the error I am getting:
With the new user and new virtualenv –
When trying to Import the AuomationHat library in the exact same .py file I prototyped, it says it can’t find it.
When trying it from the Python command line, it says it can’t find it.
Within the VirtualEnv. I have tried both curl install, and the pip-install versions without much luck.
Pip tells me it is already installed.
When checking the virtualenv/bin folder, I do NOT see the automationHat library (I do see Flask and uWSGI, so I know the virtualenv is working correctly "In Theory"™ ).
When checking the ~/Pimoroni/AutomationHat directory for the new user, I DO see the library there from the curl install… but it still can’t see it in Python.
My best guess is that it’s either
- The VirtualEnv, is causing issues (this is my gut feeling)
- The second user is causing issues (maybe because it sees it already installed for another user…).
But between the two of them, I’m not sure how the two AutomationHat Installation methods interacts with either of them…
Has anyone run into something similar? How did you fix it? Since I CAN see the library in the ~/pimoroni/automationhat directory… I’m sure this is not the preferred method, but is there a way to just point the virtualenv outside itself, to just use the dang thing, and call it a day?? I’d rather it be within the virtualenv, to “Do it right”… but failing that, I just want it to work. :P