#fastapi and blinka

1 messages · Page 1 of 1 (latest)

agile falcon
#

starting a thread

chilly sky
#

I did indeed install board.py manually, several times in several different ways to make sure it's installed

agile falcon
#

blinka is unusual. You don't do import blinka or import adafruit_blinka. Instead it provides multiple top-level modules that are in CircuitPython, like board, digitalio, etc. It is not correct to install board. That is someone else's package, totally unrelated to blinka. It just happens to have the board name

#

you need to uninstall it

#

pip uninstall board

chilly sky
#

Okay, I did

#

The error is still there

agile falcon
#

right, that's just another problem that would have had to be fixed as well. I am installing fastapi locally to see what is going on

chilly sky
#

Thank you. I commented board, now I get the same thing with busio

agile falcon
#

yup, completely expected, the fastapi enviornment doesn't have blinka

chilly sky
#

So, I would need to keep the 2 programs separate but have them communicate with eachother

agile falcon
#

hold on while I see what is going on with fastapi run

#

OK, I did the following (wait for all the input)

#
  1. create a new empty venv for testing
python3 -mvenv testing
#

deactivate my current venv:

deactivate
#

activate the new venv:

source ~/testing/bin/activate
#

install blinka and fastapi:

pip install adafruit-blinka
pip install "fastapi[standard]"
#

Test the installations:

$ python3
Python 3.12.3 (main, Mar  3 2026, 12:15:18) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import board
>>> import fastapi
>>> 
#

(then ctrl-D to exit python)

#

then did

fastapi run minimal.py
#

i did not get any import errors

chilly sky
#

Good to hear. It's currently taking it's sweet time to install Adafruit-Blinka

agile falcon
#

i am trying this on Ubuntu 24.04, not an RPi. What OS version are you running on the RPi 4?

chilly sky
#

It's running on Raspbian, the recommended install

agile falcon
#

could you do cat /etc/issue?

#

what does it print?

chilly sky
#

I'll try that when it's done installing FastAPI, Blinka is now installed

agile falcon
#

i have to walk to buy groceries, so I'll be away for a while. I can try it on an RPi 4 when I return if it is not working for you

chilly sky
#

Thanks a lot, I'll keep you informed.

#

It works to resolve the noted issues, but now adafruit_pca9685 gives the module not found error. I really need that to control the servo's and motors powering the model and the ship-load of cranes

agile falcon
#

so what I am seeing is that the previous venv you are using is messed up in some way. The venv I had you just create has only two things installed in it: adafruit-blinka and fastapi. You can now continue to add the rest of the modules you need with pip install, like adafruit -circuitpython-pca9685, etc.

#

(I had to get ready to go)

chilly sky
#

Could've thought of that myself. Thanks a lot

chilly sky
#

I have to check it tomorrow, the batteries are empty

chilly sky
#

The batteries are fully charged again and the libraries are installed. If I now run the program without FastAPI it works fine but the program with FastAPI runs into the same error, now with the PCA9685

agile falcon
chilly sky
#

Then this happens

agile falcon
chilly sky
#

This is the test, I've used this the entire time

agile falcon
#

aha, uppercase, should be lower case: from adafruit_pca9685 import PCA9685

chilly sky
#

I solved that now, still no joy

agile falcon
#

you have a capital A in Adafruit. It should all be lower case

#

from adafruit_pca9685 import PCA9685 . this is just a naming convention. The module names are lower case. The class names are capitalized, or when they are part numbers, all upper case.

chilly sky
#

Thanks, now it runs using Python3. Now lets see what happens if I run it from FastAPI

#

That works as well, thanks a lot!