2020年12月19日星期六

Have to run all python scripts with sudo

I got a new Raspberry Pi, installed Ubuntu on it, wrote a python script but when I run the script using python3 script.py it just cant find libraries that I installed using pip3 and give library missing erros.

But if I run the same script using sudo python script.py it runs.

I have given script.py permission using sudo chmod 777 script.py , yet same issue

I even gave folder permissions sudo chown user user /home/someuser/Desktop , yet same problem

Now the bigger problem is when I use basic IDE like Thonny , I cant run using sudo from the IDE itself , so I have to run the script from terminal separately which is such a pain

Here is my file permissions -rwxrwxrwx 1 someuser someuser 2528 Dec 19 17:57 script.py

Here is my folder permissions drwxr-xr-x 3 someuser someuser 4096 Dec 19 17:56 Desktop

There is no other user on the system except for the one I created during ubuntu setup

I have mostly installed all libraries using sudo pip3 install

One of the error I am getting while trying to use GPIO library

  File "/home/someuser/Desktop/beep.py", line 11, in <module>      GPIO.setup(18, GPIO.OUT)  RuntimeError: Not running on a RPi!  

Another error:

  File "/usr/lib/python3.8/socket.py", line 231, in __init__      _socket.socket.__init__(self, family, type, proto, fileno)  PermissionError: [Errno 1] Operation not permitted  

Is there a way where I dont have to use sudo every time and makes life easy and easily work with installed libraries.

Here is some additional info

/usr/lib/python38.zip  /usr/lib/python3.8  /usr/lib/python3.8/lib-dynload  /home/someuser/.local/lib/python3.8/site-packages  /usr/local/lib/python3.8/dist-packages  /usr/lib/python3/dist-packages    
someuser@pi4:~$ which python3  /usr/bin/python3  
https://stackoverflow.com/questions/65376955/have-to-run-all-python-scripts-with-sudo December 20, 2020 at 12:37PM

没有评论:

发表评论