xmlrpc.py permission denied whole running the supervisor - python

I need to run the laravel jobs in the background and for that reason, I need to run the supervisor on the Linux server.Whenever I try this
supervisorctl reread
It returns this error.
error: <class 'PermissionError'>, [Errno 13] Permission denied: file: /usr/lib/python3/dist-packages/supervisor/xmlrpc.py line: 560
I tried to change the permission of this file
chmod u+X /usr/lib/python3/dist-packages/supervisor/xmlrpc.py
It returns this error
chmod: changing permissions of '/usr/lib/python3/dist-packages/supervisor/xmlrpc.py': Operation not permitted
Any reason why it is not working? I recently upgraded the PHP to 8.1. Is this why it causing the problem?

I used to have the same problem as you, I used sudo at the beginning of the command and it worked fine
sudo supervisorctl reread

Related

python3 [Errno 13] Permission denied

I have a Laravel app running on ubuntu 22.0.4. Inside one of my controllers I try to run a python script using shell_exec():
$output = shell_exec("python3 /home/ubuntu/test.py 2>&1");
Log::debug($output);
But the script is not executed and inside my log file I get:
"python3: can't open file '/home/ubuntu/test.py': [Errno 13] Permission denied"
I have set the permission for test.py to 777, and I have tried:
sudo chown ubuntu:www-data test.py
and also,
sudo chown ubuntu:ubuntu test.py
But still the same error. I have other projects running on ubuntu 20.0.4 with the same Laravel structure and logic in which I can execute the same python script (test.py) without any problem. But, for this specific case which I am using ubuntu 22.0.4, I am facing this problem. Also, same as other projects, I used pip3 to install python3.

Server Error while saving panda dataframe to csv

part of my python script is as below
panda_dataframe.to_csv("myfile.csv")
The code is working fine in my Dev System.
I have deployed it in EC2 - Ubuntu. The above statement return Server Error (500)
I have also tried with
panda_dataframe.to_csv("/usr/share/myfile.csv")
But the same error.
Error.log has the below error.
PermissionError: [Errno 13] Permission denied: '/usr/share/myfile.csv'
I have tried with setting the below permisions
sudo setfacl -m u:www-data:rw /var/www/sitefolder/myfile.csv
sudo setfacl -m g:www-data:rw /var/www/sitefolder/myfile.csv
Guide me what is the permission I have to assign to write the dataframe into a csv file
Your working directory is /usr/share, and saving/deleting/copy/move actions in /user directory requires sudo privileges. so first check you user directory by executing echo $HOME. say the result is /home/amir. now save you data frame as:
panda_dataframe.to_csv("/home/amir/myfile.csv")

pysftp can't create log file - permission denied

I have a small service written in Python 3 which uses pysftp:
with pysftp.Connection(
host=host,
username=connection_data["user"],
port=connection_data["port"], log=log_file, cnopts=cnopts
) as srv:
…
and when I run it (python3 pythonprog.py) I get the following error:
PermissionError: [Errno 13] Permission denied: '/mydisk/folder/logs/pysftp-20181127-231208.log'
Obviously, I don't get this error if I run it with sudo python3 pythonprog.py.
I checked the permissions for this folder:
ls -l
drwxrwxrwx+ 2 myuser myuser 4096 Nov 27 22:38 logs
I also changed ACL with setfacl. Basically, whatever I do the error is still there. How can I grant this permission?
The service is running as someone -- that someone needs permission to write to that file or folder. This is not a code problem, its a permission problem. sudo is not the solution to running the code. I'm taking it that it is running as you? Can you write to that file/folder?

Django permissions hiccup

I had all my static and media files working perfectly. However, when I wanted to create a new news article and therefore upload a new picture I got the following error:
[Errno 13] Permission denied:
At the following link I found:
Django [Errno 13] Permission denied: '/var/www/media/animals/user_uploads'
sudo groupadd varwwwusers
sudo adduser www-data varwwwusers
sudo chgrp -R varwwwusers /var/www/
sudo chmod -R 770 /var/www/
Now none of my static files will display on the site at str8red.com
Can anyone help with getting the file permissions back and also allowing the webpage to allow upload of new images.
Many thanks, Alan.
Apologies,
After further digging and grasping the basics of chmod I got there. The links below were very helpful:
www-data permissions?
https://en.wikipedia.org/wiki/Chmod
Many thanks, Alan.

Chmod in Python - [Errno 1] Operation not permitted

I'm trying to modify an application in my /Applications folder on OS X. I need to get read and write permissions, so I currently have:
os.chmod(appDir, 0644)
where appDir is the directory of my app. However, whenever I run the program, I get the error:
OSError: [Errno 1] Operation not permitted: '/Applications/Simplenote.app'
I would try sudo, but how would you enter the password through Python? (this is a Python script by the way)
Any help is appreciated.
If you are trying to run the script from a web site, change the target folders/files to be owned by the web user, e.g. www-data. sudo chown www-data * -R That fixed it for me.

Categories

Resources