There is a problem here .
python py file ok!
sudo python py file : Module not found
Solution :
1. uninstall , Use sudo pip install Installation .
2. Add path of user rights to sudo Under the path :
step :
Separately :
It can be seen that it is not used sudo Of python The environment has an additional user state path .
Create a my.pth File to /usr/lib/python3/dist-packages(sudo The path of ):
Add the path of user status :
/home/XXX/.local/lib/python3.7/site-packages
Just rerun the code .