Author Topic: Troubles with external Python modules for SPI communication  (Read 1757 times)

0 Members and 1 Guest are viewing this topic.

analog_dreams

  • Zombie
  • *
  • Posts: 1
Troubles with external Python modules for SPI communication
« on: December 28, 2021, 03:06:47 AM »
Hi everyone! :)
This is my first post :D
I need to read an adc (MCP3008) in my GeeXLab scene running on a Raspberry Pi 4.
 To do so, I tried using several python modules (spidev, mcp3008, Wiring Pi for python), but as soon as I add an import of one of those external modules in the init.py file I get an error.
However, if I try to import other built-in modules (such as sys, or os), everything goes smoothly.
When I run the init script from the Thonny IDE, all the imports work correctly, the issue appears only when I launch it in the GeeXLab scene.
Does GeeXLab allow for the use of external modules? Am I missing something obvious?
« Last Edit: December 28, 2021, 02:39:11 PM by analog_dreams »

edward

  • Zombie
  • *
  • Posts: 1
Re: Troubles with external Python modules for SPI communication
« Reply #1 on: December 31, 2021, 08:00:23 PM »
I don't know if it will work, but Have you tried to set the environment PYTHONPATH:
Code: [Select]
os.environ["PYTHONPATH"]=PATH to search for py modulesA simple example:
Code: [Select]
os.environ["PYTHONPATH"]="/usr/python/my_modules:/lib/python/"
« Last Edit: December 31, 2021, 08:02:34 PM by edward »