Flask not working with Virtualenv on Raspberry Pi Flask not working with Virtualenv on Raspberry Pi flask flask

Flask not working with Virtualenv on Raspberry Pi


When you're running it as sudo, the virtualenvs python and other variables are no longer used. You can easily prove this by running sudo pip freeze or sudo pip list and comparing the output with pip freeze or list respectively.

You have (at least) two options:

  1. Run without sudo
  2. Define which python you want to use. Virtualenvs are just wrappers for environments, so you can say sudo /path/to/virtualenv/bin/python simply.py and everything should work just fine.

I use the second one often (minus the sudo) when combining supervisord configurations with different python versions in virtualenvs, for instance when deploying flask applications. Works like a charm.