Nice solution.Been there.. In this case sys.executable is usefulIf 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.So something likeA string giving the absolute path of the executable binary for the Python interpreter......gets mycode.py running in the venvCode:
await asyncio.create_subprocess_exec( sys.executable, 'mycode.py' )
Statistics: Posted by memjr — Tue Jul 16, 2024 3:37 pm