Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4398

Python • Re: How to get Python to use a custom library path

$
0
0

For your problem, I would propose this:
- execute your python programs from the work dir where the python program is located.
cd <path where yourprogram is located>
python3 <yourprogram>
- place the modules you want to use into local folder <path where your python program is located>
That's a great idea, and for specific local testing, (do the servos/drive motors release when done? Does the distance sensor work correctly?), that works.

And so far, all the advice has been specific to running a single program which is great advice, but won't work in this specific case.

Why?

SPI communication is intrinsic to the entire robot at a fundamental system level so whatever I do has to be absolutely global in nature, must exist at boot, (or whenever Python kicks in), and must persist across reboots.

This is why the many suggestions about changing the Python path won't work - they change it within the scope of one specific program, not globally.

It is obvious that a Python path is being established at boot time and I have not been able to discover where it is set.

I will try experimenting with the system path and see how that works.

P.S.
I suspect that Thonny inherits the system path or something like that since it also doesn't respect exports from .bashrc or .pypaths.

Statistics: Posted by jharris1993 — Sun Jun 30, 2024 8:57 am



Viewing all articles
Browse latest Browse all 4398

Trending Articles