General linux help with virtualenv

I’m trying to install flyte’s pi-mqtt-gpio python app on a second raspi to expose a whole bunch of GPIOs for use with HA via mqtt.

Under the Serving Suggestion topic everything was going well until I got to:

cd /home/pi
virtualenv ve

At which point I get the error:

bash: virtualenv: command not found

Any idea how I can fix this?

sudo pip install --upgrade virtualenv instead of pip install --upgrade virtualenvseems to have fixed it.

Still need help.

I have it up and running:

pi@hassio_mqtt_slave:~ $ sudo supervisorctl status
pi_mqtt_gpio                     RUNNING   pid 2717, uptime 0:00:07

Unfortunately it’s not working.

Looking at the log file I see:

Last will set on 'hassio_slave/status' as 'dead'.
Requirement already satisfied: RPi.GPIO in /usr/lib/python2.7/dist-packages
Traceback (most recent call last):
  File "/usr/lib/python2.7/", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/", line 72, in _run_code
    exec code in run_globals
  File "/home/pi/mqtt_slave/lib/python2.7/site-packages/pi_mqtt_gpio/", line 450, in <module>
  File "/home/pi/mqtt_slave/lib/python2.7/site-packages/pi_mqtt_gpio/", line 391, in configure_gpio_module
    return gpio_module.GPIO(gpio_config)
  File "/home/pi/mqtt_slave/local/lib/python2.7/site-packages/pi_mqtt_gpio/modules/", line 16, in __init__
    import RPi.GPIO as gpio
ImportError: No module named RPi.GPIO

Tried to install RPi.GPIO in the venv but got this:

pi@hassio_mqtt_slave:~ $ sudo supervisorctl stop pi_mqtt_gpio
pi_mqtt_gpio: stopped
pi@hassio_mqtt_slave:~ $ . mqtt_slave/bin/activate
(mqtt_slave) pi@hassio_mqtt_slave:~ $ sudo pip install RPi.GPIO
Requirement already satisfied: RPi.GPIO in /usr/lib/python2.7/dist-packages

I’m a total newb at this. Any help would be appreciated.

Using sudo runs the command as root user. Switching user takes you out of the virtual environment. If you need to install a python package in the virtual environment you must do so as the user that invokes the virtual environment

. mqtt_slave/bin/activate
pip install RPi.GPIO
1 Like

Magic! Thank you.

All working as expected.

1 Like