pigpio
pigpio copied to clipboard
Running pigpio on virtual environment
Hi, I wanted to ask if it is possible to use pigpio in a virtual environment?
Running the servo demo script worked for me in a non-virtual environment with the command sudo python servo_demo.py
When I activated the virtual env and proceeded with the same installation and activation steps, I am likewise able to use the demo script with the same command.
However, the problem arise if I leave out sudo
in my bash commands (i.e. python myscript.py
) since using the command sudo python myscript.py
would render another module of this script unavailable in the virtual environment.
The error message when I used the non-sudo command goes:
`Traceback (most recent call last):
File "my_script.py", line 13, in
I suspect the problem lies in the process of installation as I had to use sudo make install
in one of the steps. I think I have to install via an alternative method that avoids global installation i.e. sudo. My understanding is that only pip can install packages into a virtualenv (from Pypi) (v.s. sudo which leads to global installation). Is there a way that I can install pigpio into a virtual environment? I appreciate any advice on how I can run pigpio module without using 'sudo' in a virtual environment.
Need a Python expert to assist with this question.
While it would be nicer if the pigpio.py
was packaged on PyPI for pip-assisted installation, it's actually very easy to install pigpio.py
yourself. Just copy it into your venv's site-packages. You can find these under {sys.prefix}/lib/pythonX.X/site-packages
, and to get at the prefix just run
python -c 'import sys; print(sys.prefix)'
Ben Nuttall maintains a pigpio version on PyPy.
https://pypi.org/project/pigpio/
I do not understand how this is relevant to virtual environments.
It can be depending on the way the venv has been set up and the original poster has set it up and installed pigpio. There is for example the option to isolate venvs from system-installed packages, and that could have come into play here.