I created a program which modifies the hosts file in order to block some websites. But when I am running the programme, I am getting this error.
Btw I have created my Python file using Pycharm IDE and my intention is to run this script everytime open my PC using Task Scheduler. So please kindly do tell me what I should be running as the administrator. Is it like the Pycharm itself? Most importantly how do I give it Admin permissions permanently?
[Errno 13] Permission denied: 'C:\\Windows\\System32\\drivers\\etc\\hosts'
Please kindly tell me a way to fix this.
On Windows create a scheduled task on logon, and configure the task to run under a system account. The task could simply be run as a batch file and within the batch file you may run the below command. Ensure the task is set to run with administrator privileges in the task creation window
C:\PythonFolder\python.exe yourscript.py
Related
I have a python script that I am trying to schedule to run in the task scheduler in my VM but it doesn't seem to be running, it returns (0x2) for last run result. I am able to run the script manually and it works. I even created a batch file to execute the script which works and tried scheduling that in Task Scheduler but it also gave the same error. My only guess is that it's not working because it uses the Google Sheets API and reads the credentials from a JSON file in the project folder but I'm still unsure as to why it wouldn't run when scheduled. If you have any ideas I would greatly appreciate it. In the task scheduler, I am using the path Z:\Python\PythonGSAPI\executePy.bat to execute the batch file. The content of the batch file is
#echo off
"C:\Python27\python.exe" "Z:\Python\PythonGSAPI\TF_Invoice.py"
pause
This occur due the PATH Enviroment variable, for exemple, if you use Anaconda Python it's needed to choose the first option during the installation or even configure this after.
enter image description here
I am running a small webserver on a Raspberry Pi. I am trying to access the GPIO ports with a python script, executed via CGI from another computer on the local network.
The program runs fine when executed locally with sudo. However when I run it from another computer, CGI returns the following error :
type 'exceptions.IOError' : [Errno 13] Permission denied
I gave the file full permissions (I know it's not good, but I am the only user), I gave www-data permissions to run files. It seems I can't access the GPIO ports. I don't know which file permissions are blocking me. Can you help ?
EDIT : I found the solution, I had to add www-data to the spi group. 3 hours of searching for one bloody line in the terminal.
I am compiling a website using TeamCity on a server and need to deploy the compiled website to AWS.
As my last build step, I use the Elastic Beanstalk CLI to deploy: "C:\Python34...\eb.exe deploy".
eb init has already been run...but whenever I run "eb deploy", (even when I run it from the command line in an empty directory--which should deploy a default project to AWS), an error appears saying:
Error: PermissionError :: [Errno 13] Permission denied: './pagefile.sys'
I have already run the command on my local machine without any problems; I receive the error on the server regardless of whether I am running the command line as an administrator.
I am wondering if this is a permissions issue with the server, or something else? I haven't been able to achieve much insight from the other questions, because they seem to have been solved on a case-by-case basis.
pagefile.sys is the Windows swap file.
It is a special file which cannot be written or manipulated. Whatever your command is doing you need to fix your command so it that doesn't touch this file and ignores it.
I have simple python code on Windows that reads/writes a log file that I don't want standard users to have write access, so I have made the log files restricted to Adminstrator write privileges.
import os
l = open('filename.log', 'w')
I can't figure out how to debug it without running into a permission denied error. Debugging in PyCharm and even though starting PyCharm as admin, I get the error.
I can, however, run a python shell as admin and open/write my log file without error.
How can I run PyCharm to debug without getting the error?
After confirming that the PyCharm process is running with administrators group using accesschk as recommended by eryksun, the code is now executing without the error.
I have a Python script running on the default OSX webserver, stored in /Library/WebServer/CGI-Executables. That script spits out a list of files on a network drive using os.listdir.
If I just execute this from the terminal, it works as expected, but when I try to access it through a browser (computer.local/cgi-bin/test.py), I get a permissions error:
<type 'exceptions.OSError'>: [Errno 13] Permission denied: '/Volumes/code/code/_sendrender/queue/waiting'
Is there any way to give the script permission to access the network when accessed via CGI?
I don't know much about the default osx webserver, but the webserver process is probably being run as some user, that user needs to be able to access those files. To find out who the user is you can use the ps command. Then depending on the configuration of the network shared drive, you can add this user to the users allowed to access this data.