Greetings!
Background:
I am attempting to do some experiments with my GoPiGo3 robot, attempting to add a mutex to the SPI communication routines. I want to do this because I would like to use a GPIO Waveshare e-Paper display that uses the SPI channel that the GoPiGo controller doesn't use. [1]
There appears to be a conflict/collision between the two devices, so I want to try a mutex to force them to cooperate.
The robot is using a Pi-4 running Raspberry Pi O/S Buster.
I am using Thonny as my primary programming IDE.
Note that Buster is a hard requirement for this robot's libraries and code and it cannot be changed. (I say this because every time I say "Buster" folks say "Upgrade to Bookworm!!" and that is not possible at the present time.
There is an egg file located at /home/pi/.local/lib/python3.7/site-packages/gopigo3-1.3.2.1-py3.7.egg. This is the system default library path for the special GoPiGo3 function libraries.
I want it to use the gopigo3 library files that I have copied from that egg file into /home/pi/Test_Libraries, entirely ignoring the existing egg file.
The reason for this is I want to specify my experimental files that I will edit to create a mutex wrapper around the existing SPI code. In order to do this, I have to be able to guarantee that my local python libraries are being used instead of the default libraries within the egg file.
Issue:
I want to force the python path to somewhere else for certain libraries and it doesn't seem to work.
Looking around the internet, I have done the following based on suggestions from Stack Overflow and others:
Set the python path within a terminal window:Restarting Thonny I see the following in the RPL shell:I edited the .pypath file as follows:Then I added the following to the end of the .bashrc file:I rebooted the robot and then executed the following in a terminal:. . . and it returns the desired path.
However, when I open Thonny and run:I get the following response in the RPL window:Note that this is still the default system path to the library .egg file instead of my custom installation of these libraries.
Request:
How do I:
1. Set the python path for my libraries at the system level so every robot function uses these libraries?
2. Set the python path so that Thonny uses the desired path when I am testing code in Thonny?
Thanks in advance for any help you can provide.
========== Footnotes: ==========
1. The GoPiGo3 controller board is set to use chip-select-1 (CS-1) and the Waveshare e_Paper display is set to use chip-select-0 (CS-0)
Background:
I am attempting to do some experiments with my GoPiGo3 robot, attempting to add a mutex to the SPI communication routines. I want to do this because I would like to use a GPIO Waveshare e-Paper display that uses the SPI channel that the GoPiGo controller doesn't use. [1]
There appears to be a conflict/collision between the two devices, so I want to try a mutex to force them to cooperate.
The robot is using a Pi-4 running Raspberry Pi O/S Buster.
I am using Thonny as my primary programming IDE.
Note that Buster is a hard requirement for this robot's libraries and code and it cannot be changed. (I say this because every time I say "Buster" folks say "Upgrade to Bookworm!!" and that is not possible at the present time.
There is an egg file located at /home/pi/.local/lib/python3.7/site-packages/gopigo3-1.3.2.1-py3.7.egg. This is the system default library path for the special GoPiGo3 function libraries.
I want it to use the gopigo3 library files that I have copied from that egg file into /home/pi/Test_Libraries, entirely ignoring the existing egg file.
The reason for this is I want to specify my experimental files that I will edit to create a mutex wrapper around the existing SPI code. In order to do this, I have to be able to guarantee that my local python libraries are being used instead of the default libraries within the egg file.
Issue:
I want to force the python path to somewhere else for certain libraries and it doesn't seem to work.
Looking around the internet, I have done the following based on suggestions from Stack Overflow and others:
Set the python path within a terminal window:
Code:
pi@CharlineWiFi:~ $ export PYTHONPATH=${PYTHONPATH}:/home/pi/Test_Libraries/easygopigo3.pypi@CharlineWiFi:~ $ export PYTHONPATH=${PYTHONPATH}:/home/pi/Test_Libraries/easysensors.pypi@CharlineWiFi:~ $ export PYTHONPATH=${PYTHONPATH}:/home/pi/Test_Libraries/gopigo3.pypi@CharlineWiFi:~ $ echo ${PYTHONPATH}:/home/pi/Test_Libraries/:/home/pi/Test_Libraries/easygopigo3.py:/home/pi/Test_Libraries/easysensors.py:/home/pi/Test_Libraries/gopigo3.pypi@CharlineWiFi:~ $
Code:
Python 3.7.3 (/usr/bin/python3)>>> import easygopigo3 as easy>>> print(str(easy))<module 'easygopigo3' from '/home/pi/.local/lib/python3.7/site-packages/gopigo3-1.3.2.1-py3.7.egg/easygopigo3.py'>>>>
Code:
/usr/local/lib/python2.7/dist-packages/gopigo3-1.2.0-py2.7.egg/usr/local/lib/python2.7/dist-packages/gopigo3-1.2.0-py2.7.egg/home/pi/Test_Libraries/*/home/pi/Test_Libraries/easygopigo3.py/home/pi/Test_Libraries/easysensors.py/home/pi/Test_Libraries/gopigo3.py
Code:
# export python pathexport PYTHONPATH=${PYTHONPATH}:/home/pi/Test_Libraries/:/home/pi/Test_Libraries/easygopigo3.py:/home/pi/Test_Libraries/easysensors.py:/home/pi/Test_Libraries/gopigo3.py
Code:
pi@CharlineWiFi:~ $ echo ${PYTHONPATH}:/home/pi/Test_Libraries/:/home/pi/Test_Libraries/easygopigo3.py:/home/pi/Test_Libraries/easysensors.py:/home/pi/Test_Libraries/gopigo3.pypi@CharlineWiFi:~ $
However, when I open Thonny and run:
Code:
import easygopigo3 as easyprint(str(easy))
Code:
Python 3.7.3 (/usr/bin/python3)>>> %Run Python_Path.py<module 'easygopigo3' from '/home/pi/.local/lib/python3.7/site-packages/gopigo3-1.3.2.1-py3.7.egg/easygopigo3.py'>>>>
Request:
How do I:
1. Set the python path for my libraries at the system level so every robot function uses these libraries?
2. Set the python path so that Thonny uses the desired path when I am testing code in Thonny?
Thanks in advance for any help you can provide.
========== Footnotes: ==========
1. The GoPiGo3 controller board is set to use chip-select-1 (CS-1) and the Waveshare e_Paper display is set to use chip-select-0 (CS-0)
Statistics: Posted by jharris1993 — Sat Jun 29, 2024 1:40 pm