Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Python script that I run which needs to execute under a special environment, so I would run the program like so from my working directory (~/project/src):

python shell

This opens up an interactive shell for me to start typing my own commands.

I have another set of administrative activities that I would like to house in another directory (~/project/admin). The is really finicky about running from the working directory. So, to make this whole thing work, I made a script which starts off like so:

#!/usr/bin/python ../src/ shell

There are a couple problems with this. The first is that it doesn't work:

/usr/bin/python: can't open file '"/../src/" shell': [Errno 2] No such file or directory
  • How do you specify multiple parameters to the interpreter?
  • How do I change the working directory?
share|improve this question
This looks like a Django environment. You may get better responses on – Doug Harris Feb 2 '11 at 16:44
@Doug: It started out as Django, but has been magnificently altered at this point. My only problem now is script-related, so I figured that should go here. – Travis Gockel Feb 2 '11 at 16:50
up vote 2 down vote accepted

You can only specify one argument to the interpreter. I don't think you can use relative directories in it either.

I would suggest that you wrap what you need to do in a shell script or a Python script that uses Popen() to call it perhaps.

share|improve this answer
It varies depending on the OS. – grawity Feb 2 '11 at 17:44

Assuming that I'm correct in my guess that you're in a Django environment...

Take a look at James Bennet's article about Standalone Django Scripts. Look at the section about "Use setup_environ()" which mentions that this is "exactly how Django’s own script handles settings".

There's a similar question on stackoverflow which will probably help you as well.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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