How a Python venv works
When you activate a virtual environment, your PATH variable is changed to include the virtual environment. You can see this by printing the path with echo $PATH.
You don’t need to activate a virtual environment, you can just specify the full path to that environment’s Python interpreter when invoking Python.
E.g. ~/.local/gpiod/bin/python Myprogram.py
You can also use a “shebang” line which points to the environment’s Python interpreter,
i.e. #!<path-to-venv>/bin/python (the <path-to-venv> MUST be a fully qualified path).
This is how scripts installed into the virtual environment work.
When you activate a virtual environment, your PATH variable is changed to include the virtual environment. You can see this by printing the path with echo $PATH.
You don’t need to activate a virtual environment, you can just specify the full path to that environment’s Python interpreter when invoking Python.
E.g. ~/.local/gpiod/bin/python Myprogram.py
You can also use a “shebang” line which points to the environment’s Python interpreter,
i.e. #!<path-to-venv>/bin/python (the <path-to-venv> MUST be a fully qualified path).
This is how scripts installed into the virtual environment work.
Statistics: Posted by Milliways — Mon Jul 07, 2025 1:00 am