1

I'm have a problem where if I double click my script (.py), or open it with IDLE, it will compile and run correct. However, if I try to run the script in my windows command line, using

C:\> "C:\Software_Dev\Python 2.7.1\python.exe" C:\path\to\script\script.py

I get...

Traceback (most recent call last):
  File "C:\path\to\script\script.py", line 66, in <module>
    a.CheckTorrent()
  File "C:\path\to\script\script.py", line 33, in script
    self.WriteLog(fileName)
  File "C:\path\to\script\script.py", line 54, in WriteLog
    myFile = open(r'%s' %(filename), 'w')
IOError: [Errno 13] Permission denied: './TorrentMonitor.log' 

So my question is, why am I getting permission errors when I run this script through command line in window 7 but not when I double click? What's the difference between those two processes?

Thanks in advance!

2 Answers 2

1

The script is trying to write into a file in the current directory. In the example above, you're starting it from C:\ where you probably don't have write permissions.

cd to a directory that you own, and you should be able to run that command just fine.

Sign up to request clarification or add additional context in comments.

Comments

0

This is because when you double-click the file (or when running it from IDLE), the current working directory is the directory that contains your script. When starting it from the command line, it's C:\ which you don't seem to have write access to.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.