[Resolved] Where do my action-file Python modules belong?

I am trying to add some Adafruit DotStar LED code to my actions…

I installed the adafruit_circuitpython_dotstar library per [https://learn.adafruit.com/adafruit-dotstar-leds/python-circuitpython]…

I installed it using both “sudo pip3…” (installed yesterday) and “sudo -u _snips-skills…” (installed today)…

I see that the library is installed with root as the owner in /usr/local/lib/python3.5/dist-packages …the file date is from yesterday’s install…I do not see any files from today’s install (though it did say it was installed at the CLI today)…

I can run python scripts at the CLI using an “import adafruit_dotstar” statement and they run fine…

If I place the same statement in my action file, when I run update-assistant, I get an error regarding …setting up the virtualenv - that it could not find a version that satisfies my requirements.txt, and if I look in the snips-skill-server -v, it says that there is an ImportError: No module named "adafruit_dotstar’

I added a sys.path.append("/usr/local/lib/python3.5/dist-packages"), but it only lessened the update-assistant errors…

I have searched hi-n-lo but have to assume at this point it is in my ignorance of Linux, or snips, or both…

its because snips action apps are installed in a virtual environment
your install of the adafruit is on your system, but not accessible within the virtualenv

load your action app directory virtualenv and install the pip adafruit lib in there to use it

Hi ozie - thanks for looking at this for me…

So, I did the following:

I saw where many of the packages were in a venv (lower case) dist-packages directory of my skill…so, I tried the following at the RPi CLI:

cd /var/lib/snips/skills/snips-app-voicekit
sudo -u _snips-skills python3 -m venv venv
. venv/bin/activate [I now saw <venv> preceeding the CLI prompt]
sudo -u _snips-skills pip3 install adafruit-blinka
sudo -u _snips-skills pip3 install adafruit-circuitpython-dotstar
deactivate

My requirements.txt:

 # Bindings for the hermes protocol 
hermes-python>=0.1.29
grove.py>=0.6

# More dependency goes here.. 
pyserial==3.2.1
board
adafruit_dotstar

When I then did a Sam update-assistant, there was the same error…

and, still got the ImportError: No module named ‘adafruit-dotstar’ when running snips-skill-server

Checked the venv folder again after above and see lots of packages in the dist-packages folder but no adafruit-circuitpython-dotstar one…[note that in /usr/local/lib/python3.5/dist-packages, where the original package installed, adafruit_dotstar.py lives in the directory, but outside of the adafruit_circuitpython_dotstar-1.5.0.dist-info folder, if that might make a difference]…

So, though it appeared I installed into the virtual environment, I don’t think so…

Sorry for the pile of ignorance here (but trying), and, certainly do appreciate your help)…

Regards, Frank

shouldn’t you requirements.txt file have adafruit-circuitpython-dotstar and not adafruit_dotstar ?

the error says could not find a version that satisfies the requirement adafruit_dotstar … that is pip’s way of saying it doesn’t know what lib that is and can’t install it

the python import name is not necessarily the name of the pip install name

Hi ozie,

The import command that is shown in the examples on Adafruit’s web site, (https://learn.adafruit.com/adafruit-dotstar-leds/python-circuitpython) and which I tested using a simple Python3 script, is adafruit_dotstar …e.g.:

import board
import adafruit_dotstar as dotstar
dots = dotstar.DotStar(board.D6, board.D5, 30, brightness=0.2)

but, I wondered about that also, which is why I pointed it out for you as to how the directory/file structure appears in the /usr/local/lib/python3.5/dist-packages location - the package installed there as adafruit_circuitpython_dotstar-1.5.0.dist-info, and the adafruit_dotstar.py file (called in the import statement) is just a file sitting in the same directory as the package…I wish I could show you but I do not know how to take a screen shot in Raspbian…

As you can see from above, what I thought I was installing and appeared to install with a confirmation, i.e., was sudo -u _snips-skills pip3 install adafruit-circuitpython-dotstar …not sure where it got installed if not in the skill’s venv folder?

Maybe I do not understand the install sequence with snips…since I see all the other packages in the skills venv folder, I assume when I installed the package in the virtual environment, it should show up there right after the install? Or, would it not show up there until the sam install/update-assistant routine runs?

I tried once before doing as you suggest (use the package name) when placing it in the requirements.txt file, but that did not work…I will try today to use the adafruit_circuitpython_dotstar-1.5.0.dist-info name, but again I am thinking it’s not in the venv folder anyway so it will not find that either…please clue me in on the install sequence though (paragraph here above)…

Regards, Frank

ozie,

Feel so dumb…spent another day chasing this issue…

You were right - I needed to place both the adafruit-blinka and adafruit-circuitpython-dotstar packages into the requirements.txt and all was well…

I kept thinking that since the call in the code was to the adafruit_dotstar.py file, that’s what needed to go into the reqmt’s…so, I spent all day trying to figure out how to install those packages into the venv manually (_snips-skill user issues there), when all I had to do was include them in the requirements.txt file and let Sam do it - when the packages install, the two files I needed are broken out and install in the venv separately…

Anyway, I can move on and again appreciate your help/insight! Sooner or later I am going to understand all this stuff (well, a lot of it!)…

Best regards, Frank

1 Like