Search code examples
python-3.xraspberry-pisudo

ImportError: No module named pyaudio with sudo


I am trying to run a python3 script using sudo on raspberry pi, but it is always giving me an import error the first line, in my case "module pyaudio is not found".

I have tried changing the sudoers file and putting in an env_keep += "my_python_path" like this post : PYTHONPATH not working for sudo on GNU/Linux (works for root) but it doesn't seem to work.

However, when I run sudo with python2 or when I run python3 without sudo the import errors don't happen. Any suggestions on how to get it work with python3?


Solution

  • I just used sudo su to gain root access and everything worked fine.