micgeronimo
micgeronimo

Reputation: 2149

Is there any difference in using: python manage.py [something] or ./manage.py [something]

I'm wondering if there any difference in using of following constructions? python manage.py [something] or ./manage.py [something]

Maybe there is preffered command for one statement like runserver and another for syncdb for example?

Upvotes: 4

Views: 601

Answers (2)

FunkySayu
FunkySayu

Reputation: 8061

There's no huge difference, except 2 things :

  1. You have to give the execute right to your file manage.py (chmod +x manage.py)
  2. The file has to contain for example #!/usr/bin/python at the top.

Upvotes: 2

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83438

When invoking Python script via:

./script.py 

.. it uses the Python interpreter defined in the script head. This should point to the Python interpreter defined in the environment, though sometimes (rarely) this might not be the case if the script author has not put in a proper head.

When invoking Python script via:

python script.py

... it uses Python interprefer from PATH environment variable, usually pointing to the currently activated virtualenv. This is what you get if you run which python command.

In most situations the Python interpreter should be the same.

You could also do:

/usr/bin/python script.py

... to force the usage of system-wide Python installation.

EDIT: Clarified the script head part.

Upvotes: 6

Related Questions