0

I like having my .py files open with my IDE, PyScripter. That is, when I double-click on a .py file, it opens in my IDE.

The problem is that when I want to run a python script that isn't in the current directory (e.g. it is in c:\Python27\Scripts), I can't do python script_in_path.py or I get the error

Can't open file 'script_in_path.py': [Errno 2] No such file or directory

If I change the file association for .py files (e.g. by right-clicking, open with, always use python), I can do script_in_path.py with no problem. But I don't want .py files associated with the python interpreter!

How can I make python script_in_path.py work while still having .py files associated with my IDE?

https://stackoverflow.com/questions/5299241/cant-open-file-django-admin-py-errno-2-no-such-file-or-directory is related, except the answers all boil down to associating .py files with the interpreter, which is what I do not want to do.

0

ah, like a path command for data files / like having other directories treated as current directory. don't know.. I often use pushd. C:\agrap>pushd c:\blah\long\otherdir <ENTER> then I can change back to the previous directory with popd. Or you could use doskey macros C:\>doskey abc=cd c:\windows <ENTER> C:\>doskey abcd=cd c:\program files <ENTER> then do abc<ENTER> or abcd<ENTER> to go from one directory to another. Or a batch file to change dir. Funnily enough, there is the append command , an ancient DOS command, but

I don't think it works in NT, at least not in XP.

http://pcsupport.about.com/od/commandlinereference/tp/command-prompt-commands-p1.htm

Append

The append command can be used by programs to open files in another directory as if they were located in the current directory.

The append command is available in MS-DOS as well as in all 32-bit versions of Windows. The append command is not available in 64-bit versions of Windows.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/append.mspx?mfr=true

Append Enables programs to open data files in specified folders as if these files were in the current folder. Used without parameters, append displays the appended directory list. Windows XP does not use this command. It is accepted only for compatibility with MS-DOS files.

So I can only see those workarounds to the old DOS append command. pushd popd, or doskey macros. or a batch file. or 2 cmd windows one in one directory one in another. Or specifying the full path of the data file. Or writing a bat file python.bat or mypython.bat that tries each directory to see if the file is there and runs it where it exists!

  • Yeah, unfortunately, I've resorted to making redirecting/alias batch files (a la Chocolatey) for the really often used scripts. But it's not ideal. – Pat Oct 21 '13 at 2:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.