Python Can't Access Windows 7 User Folder - python

I have a wxPython app that writes user data to the Users folder at close. In most cases it works fine. However, I get some error reports from users that the app cannot write to the Users/username folder.
IOError: [Errno 13] Permission denied: u\'C:\\Users\\usersname\\AppData\\Roaming\\app\\data.dat\'
What situation can cause a user not to be able to write to their own user folder? Does the user not always have read/write permissions to their own Users/username folder? How can I compensate for this issue?
Thanks.

A possible reason is that the file is locked. In this case you have no permission to write to the file until it is released.
Are you sure you don't lock the file somehow yourself?!

Related

Please verify that you have permissions to write to the parent directory

I'm installing Google Cloud SDK from my terminal.
Then, I got an error when I typed ./install.sh.
It shows
WARNING: Could not setup log file in /Users/myname/.config/gcloud/logs, (Error: Could not create directory [/Users/myname/.config/gcloud/logs/2022.06.18]: Permission denied.
Please verify that you have permissions to write to the parent directory..
The configuration directory may not be writable. To learn more, see https://cloud.google.com/sdk/docs/configurations#creating_a_configuration
Though I clicked "Yes" in Do you want to help improve the Google Cloud CLI (y/N)?
It still shows [Errno 13] Permission denied: '/Users/myname/.config/gcloud'
Does anyone meet the same issue? I've found some solution on Stackoverflow and other websites, but none of them are useful for me.
I had this issue. I solved by:
Open Finder
CMD+SHIFT+G
Input ~/.config
If gcloud directory does not exist, create it.
Right Click gcloud directory > Get Info > Sharing & Permissions > Give "Read & Write" to all levels.
I do not know if this is safe, but it allowed installation to complete.

Permission denied when django writes to external device

I have a django file server. The server works perfectly on my laptop & localhost (with external hard drive) but when I transferred it to my Raspberry Pi running Raspbian, it starts acting up.
I did a lot of googling and tried every possible solution but it does not work.
Here is my problem:
I have connected an external hard drive to my raspberry pi. I believe it has write permissions because I can easily write to it with mkdir. I have also set this directory which is /media/pi/SAMSUNG/media as my MEDIA_ROOT.
Now I have set up Apache2, WSGI and Django, everything works, I have set up all the permissions and everything, but still when django tries to access the hard drive, whether it be to read or write, I get an error [Errno 13] Permission denied: '/media/pi/SAMSUNG'.
I have fixed this in the past with chown -R 777 but it does not work this time.
Unfortunetly, I have no idea what I am doing when it comes to servers and file permissions, so I have no idea what code to attach. Can some please help me?
I will attach all the necessary code on request.
Thank you
On raspbian you have to be careful when using external drives. Have you edited the file /etc/fstab? This is necessary to mount the drive also correctly after restarts and when the file is temporarily disconnected and then connected again.
If you did this correctly, then the drive will have the permissions you gave it when mounting and Django should be able to access it/write to it.
BR

Python script can't write file

I have a Flask app hosted on a Linode server. I have a script to fetch a json and write it to a file. When I run this script getprice.py on my server I get the error [Errno 13] Permission denied: 'app/static/prices.json. It works fine on my local machine though. What do I have to do to get it working?
The answer is in your question. The user your script is running as on the server doesn't have write permissions on 'app/static'. It may be helpful if you also posted the getprice.py code, but it seems like a pretty straightforward file permission problem.

apache server can't write to logs

Not certain if this belongs here or on SU
I'm developing a Django app and I'm having a problem with logfiles. I have a logger configured to write to /var/log/django/django.log. When I try to start the server, I get a 500 error, and the error log says
ValueError: Unable to configure handler 'djangologfile': [Errno 13] Permission denied: '/var/log/django/django.log'
"httpd/error_log" 480L, 61112C
The permissions for both django.log and the django directory are 777. Why can't the server write to the file?
Well, the easy way to test this is to sudo as a user the server is running under and try to ls /var/log/django/django.log. If that fails you might get insight into what the problem is.

Permission denied on tools/python after chocolatey install?

Even though I have admin rights, I continue getting permission denied errors when writing to the files inside my chocolatey python installation. Why, how can I fix that?
PermissionError: [WinError 5] Access is denied: 'c:\\tools\\python\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'
Somehow the SYSTEM user was assigned owner of the folder, and permissions were set in a way that prevented access, changing of the permissions, etc.
The solution was to reassign ownership of the folders to the Administrators group/user/whatever. Then I was able to change things. Weird Windows world of permissions.

Categories