This is a followup to this question.

The first step in the Django tutorial says to call

django-admin.py startproject mysite

But here is the result:

R:\jeffy\programming\sandbox>django-admin.py startproject mysite
Usage: django-admin.py subcommand [options] [args]

Options:
  -v VERBOSITY, --verbosity=VERBOSITY
                        Verbosity level; 0=minimal output, 1=normal output,
                        2=verbose output, 3=very verbose output
  --settings=SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath=PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Raise on exception
  --no-color            Don't colorize the command output.
  --version             show program's version number and exit
  -h, --help            show this help message and exit

Type 'django-admin.py help <subcommand>' for help on a specific subcommand.

Available subcommands:

[django]
    check
    compilemessages
    createcachetable
    dbshell
    diffsettings
    dumpdata
    flush
    inspectdb
    loaddata
    makemessages
    makemigrations
    migrate
    runfcgi
    runserver
    shell
    sql
    sqlall
    sqlclear
    sqlcustom
    sqldropindexes
    sqlflush
    sqlindexes
    sqlinitialdata
    sqlmigrate
    sqlsequencereset
    squashmigrations
    startapp
    startproject
    syncdb
    test
    testserver
    validate
Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.).

R:\jeffy\programming\sandbox>

This is very different than what was happening earlier today (there was an old Python hidden in an unrelated application's install directory--it's been eliminated and removed from the PATH).

This also doesn't work

python django-admin.py startproject mysite

Result:

python: can't open file 'django-admin.py': [Errno 2] No such file or directory

And this doesn't either:

c:\applications\programming\python_341\Scripts\django-admin.py startproject mysite

Response:

R:\jeffy\programming\sandbox>c:\applications\programming\python_341\Scripts\django-admin.py startproject mysite
Usage: django-admin.py subcommand [options] [args]

Options:
  -v VERBOSITY, --verbosity=VERBOSITY
                        Verbosity level; 0=minimal output, 1=normal output,
                        2=verbose output, 3=very verbose output
  --settings=SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath=PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Raise on exception
  --no-color            Don't colorize the command output.
  --version             show program's version number and exit
  -h, --help            show this help message and exit

Type 'django-admin.py help <subcommand>' for help on a specific subcommand.

Available subcommands:

[django]
    check
    compilemessages
    createcachetable
    dbshell
    diffsettings
    dumpdata
    flush
    inspectdb
    loaddata
    makemessages
    makemigrations
    migrate
    runfcgi
    runserver
    shell
    sql
    sqlall
    sqlclear
    sqlcustom
    sqldropindexes
    sqlflush
    sqlindexes
    sqlinitialdata
    sqlmigrate
    sqlsequencereset
    squashmigrations
    startapp
    startproject
    syncdb
    test
    testserver
    validate
Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.).

But this does:

python c:\applications\programming\python_341\Scripts\django-admin.py startproject mysite

I repeated all these commands, after following this tip:

Comment out the entire django-admin.py file, and add this at the top: import sys; print(sys.version, sys.executable)

Command:

django-admin.py startproject mysite

Response:

3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] C:\applications\programming\python_341\python.exe

Command:

python django-admin.py startproject mysite

Response:

python: can't open file 'django-admin.py': [Errno 2] No such file or directory

Command:

c:\applications\programming\python_341\Scripts\django-admin.py startproject mysite

Response:

3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] C:\applications\programming\python_341\python.exe

Command:

python c:\applications\programming\python_341\Scripts\django-admin.py startproject mysite

Response:

3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] C:\applications\programming\python_341\python.exe

As an additional piece of evidence:

[R:\]python
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

As suggested here (thanks to @Humdinger), this may be a PATH issue. Earlier today there was an old version of Python in a non-obvious directory, which I deleted.

Here is my PATH

C:\applications\programming\python_341\;
C:\applications\programming\python_341\Scripts;
C:\applications\programming\;
.;
C:\Program Files\Common Files\ArcSoft\Bin;
C:\Program Files\Common Files\Microsoft Shared\Windows Live;
C:\Program Files\Windows Live\Shared;
C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Windows\system32;
C:\applications\programming\apache-ant-1.8.1\bin;
C:\applications\programming\apache-maven-3.1.1\bin;
C:\applications\programming\jdk_7_51\bin;
C:\applications\video\quicktime\QTSystem\;
C:\Program Files\TortoiseSVN\bin;
%M2%;
C:\applications\utilities\gpg4win\pub

I went through every one of these directories and did a dir *python*. The only files matched are the following:

  • python34.dll in C:\Windows\System32 (don't understand what this is)
  • python.exe and pythonw.exe in C:\applications\programming\python_341
  • ipython and ipython3 in C:\applications\programming\python_341\Scripts\

FYI: Django version 1.7c2, Python version 3.1.4, Windows 7, 32-bit.

Any ideas on what's going here? Why can't this command be reduced in any way, without causing an error?

  • Have you gone into windows and removed the association for *.py files to python.exe? – Nick Humrich Jul 31 '14 at 21:34
  • do me a favor and do django-admin.py --version just to see what happens. I dont care about the version, I am just curios if the output is correct behavior. – Nick Humrich Jul 31 '14 at 21:41
  • I created the association, as I mentioned in my previous question: I associated "'.py' files to open with C:\applications\programming\python_341\python.exe by default (I did this via right clicking ...\python_341\Scripts\django-admin.py in explorer, selecting 'Open with...', and then browsing to python.exe and selecting it." After that, yes, I deleted it. – aliteralmind Jul 31 '14 at 23:07
  • I removed it following these instructions. I'm going to reinstate it after answering your other question. – aliteralmind Jul 31 '14 at 23:16
  • @Humdinger django-admin.py --version --> TCC: Could not load Python dll. That can't be good. – aliteralmind Jul 31 '14 at 23:17

i got the same problem with django and got the solution at https://docs.djangoproject.com/en/1.7/howto/windows/ . It's mentioned there that if you are using Django 1.7 then we have to write django-admin instead of django-admin.py from our command prompt. hope it helped.

We have very similar problem but I was able to fix it without having to go through half of your troubleshooting steps.

Turns out, I have the ;C:\Python34\Scripts\ path present in both User variables for... and System Variables. I may have added the path to user variables accidentally and forgot to delete it.

Delete the ;C:\Python34\Scripts\ path in your User variables for... and it should fix the problem.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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