简体   繁体   中英

Python doesn't recognize cv2 when running under sudo

I've installed opencv with python 2.7 using this tutorial . I've created a test python file and everything works fine. But when I try to run it as sudo, it throws an error:

ImportError: No module named cv2

I'm guessing this has to do with permissions.. I need to run it as sudo because I'm using pigpiod in another function.

Any thoughts?

This problem was caused because when I installed opencv I created it in a virtual env. Making a link to the opencv file from outside the env to the opencv library folder fixed it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM