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

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

$
0
0
If your python program launches another python process (I've seen this kind of crazy thing...) that new python process will not have any knowledge of whether it's in a venv or not.

The way you ensure it runs in the venv, properly, is to specify the full path of the python interpreter in your venv's bin folder.
Been there.. In this case sys.executable is useful
A string giving the absolute path of the executable binary for the Python interpreter......
So something like

Code:

await asyncio.create_subprocess_exec( sys.executable, 'mycode.py' )
gets mycode.py running in the venv
Nice solution.

Statistics: Posted by memjr — Tue Jul 16, 2024 3:37 pm



Viewing all articles
Browse latest Browse all 3862

Trending Articles