Opened 12 years ago

Closed 11 years ago

#18410 closed Uncategorized (duplicate)

Django code installation issues on Windows Vista

Reported by: trumpetpaul@… Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Dear Django support staff,

I just ran into a ton of frustration over something simple while trying to follow your manual installation instructions.

You say in your description:

If you're using Windows, start a command shell with administrator privileges and run the command "python setup.py" install. This will install Django in your Python installation's "site-packages" directory.

However, this will produce an error that the command "python" is not recognized. If you go back a level in the directories and try to do it again, "python" is recognized but it cannot find the "setup.py" file.

The correct command to type in is simply "setup.py" with no "python" from the extracted django folder.

Seems simple but threw me off for hours!

I'd suggest changing this in the online installation instructions, as I had to search through a number of developer blogs all morning to figure out what I was doing wrong.

Thanks,

-Paul

Change History (7)

comment:1 by anonymous, 12 years ago

Correction on my description - the correct command is "setup.py install" from the windows shell, as opposed to "python setup.py install"

Thanks!

-Paul

comment:2 by Ramiro Morales, 12 years ago

Triage Stage: UnreviewedDesign decision needed

From what you decribe your enviroment seem to be such that:

However, this will produce an error that the command "python" is not recognized

Your Python setup is such that it isn't callable from anywhere (i.e. the path to the directory containing the python.exe interpreter binary, usually C:\pythonXY, hasn't been added to the PATH environment variable).

This is something that the installers of current Python versions doesn't do automatically for you but there are efforts underway to fix this for future versions.

In any case it is something that has to do with the installation of Python. (IMHO) the scope of the Django installation instructions doesn't include explaining how cope with the particularities of the local Python setup, it is assumed the developer already has that aspect under control.

Note that if you decide to not add C:\pythonXY to the PATH env var then you can simply perform the Django installation using:

C:\pythonXY\python setup.py install

Again, this is something not Django-specific.

Now what surprises me from your report is this:

If you go back a level in the directories and try to do it again, "python" is recognized but it cannot find the "setup.py" file.

This seem to indicate that the directory you are located at when performing this Django installation task (the one containing the setup.py file) is a directory under C:\pythonXY (that's why when you go up one level you can execute python.exe successfully). It means you've decompressed the Django .tar.gz distribution in a directory under C:\pythonXY.

This is actually a very strange place to use as a temporary location to uncompress the installation files. I'd suggest to choose another place or at least make sure you remove that temoprary directory once you've installed Django succesfully.

Once again it'd say this is common wisdom that applies to the installation of any Python library/module under the platform of choice (Windows in this case). Trying to learn [to use] both Python and Django at the same time isn't going to be a smooth sailing.

comment:3 by Ramiro Morales, 12 years ago

I forgot to say that we aren't going to change our installation intructions to suggest simply using

setup.py install

Because that assumes the file association for files ending in .py is correctly set up to be transparently and correctly handled by the OS so execution of suchs script is done through the correct python.exe interpreter binary.

IMHO you can consider yourself lucky if you got it to work correctly. I say this because there are:

  • facilities provided by the Window OS
  • A number of thir party hacks

that are supposed to perform this association and save us fom having to type the 'python ' prefix to execute Python scripts. Unfortunately all of them are horrible hacks that do more harm that good because they fail when the Python script is passed a certain number of command line arguments, or there is a space in the path to the Python interpreter bynary, or in the path of the Python script, etc. etc.

I say this with the experience if having read many mailing list/forum posts by people suffering from problems like "I execute setup.py foo or manage.py bar on Windows and what I get is a Notepad windows with the text of the setup.py|manage.py file".

Btw, this is something that also is in process of being solved in the Python Windows installation realm by (see PEP 397 and Google for "pylauncher")

Last edited 12 years ago by Ramiro Morales (previous) (diff)

comment:4 by anonymous, 12 years ago

Thank you for the feedback and explanations.

So, I tried this all over again on my desktop machine (also Windows Vista 32-bit).

First, I install Python 2.7 for Windows 32 bit.

I also manually added the following folders to my PATH environment variable as you suggest (I had done this before as well on my laptop):

C:\Python27\;C:\Python27\Scripts;

I then downloaded and installed the Postgresql compiled windows version located at:
http://stickpeople.com/projects/python/win-psycopg/

Next I download the compressed Django .tar.gz file and extracted it to a different folder (not near or beneath the c:\Python27 folder that contains my Python installation).

I then tested to see if the windows cmd shell would recognize "python" as a command from several different directory locations, and it does.

After doing this, I navigated to the directory containing the django installation files (and the setup.py file)

I typed in the cmd prompt:
python setup.py install

It seemed to be working! In that a ton of copying and sripting stuff seemed to be happening in the command window for a minute or so.

However, after everything was done, I opened up the Python IDLE Shell and type "import django" and I get the following error:

Traceback (most recent call last):

File "<pyshell#0>", line 1, in <module>

import django

ImportError: No module named django

I think this might have been what happened on my laptop before, which made my think I had things in the wrong folders, so I started moving things around.

Any clue what I am doing wrong?

Thanks for the help,

-Paul

comment:5 by anonymous, 12 years ago

Could this have something to do with the way PYTHONPATH and possibly other path variables are set / default-configured?

There are some links in the help documentation:

http://docs.python.org/using/windows.html

However, I think I followed instructions as they are given, so not sure what I am doing wrong.

-P

in reply to:  4 comment:6 by Ramiro Morales, 12 years ago

Replying to anonymous:

So, I tried this all over again on my desktop machine (also Windows Vista 32-bit).

First, I install Python 2.7 for Windows 32 bit.

I also manually added the following folders to my PATH environment variable as you suggest (I had done this before as well on my laptop):

C:\Python27\;C:\Python27\Scripts;

[...]

Next I download the compressed Django .tar.gz file and extracted it to a different folder (not near or beneath the c:\Python27 folder that contains my Python installation).

I then tested to see if the windows cmd shell would recognize "python" as a command from several different directory locations, and it does.

After doing this, I navigated to the directory containing the django installation files (and the setup.py file)

I typed in the cmd prompt:
python setup.py install

It seemed to be working! In that a ton of copying and sripting stuff seemed to be happening in the command window for a minute or so.

However, after everything was done, I opened up the Python IDLE Shell and type "import django" and I get the following error:

Traceback (most recent call last):

File "<pyshell#0>", line 1, in <module>

import django

ImportError: No module named django

I think this might have been what happened on my laptop before, which made my think I had things in the wrong folders, so I started moving things around.

Any clue what I am doing wrong?

You seem to have to performed a very clean installation. I've just tried the same here (except the psycopg installation) on Windows 7 x86_64, Python 2.7.3 and didn't suffer the same problem with IDLE.

Things that occur to me could have happened in your case:

  • The command shell where the installation procedure was executed wasn't opened with administrator privileges.
  • There are more than one Python installation, Django got installed in one of them and the IDLE you are running is from the another.
  • You had IDLE open from before installing Django and it doesn't see the updated

There is no need to tweak with the PYTHONPATH enviromnent variable. Even more, it isn't needed and could break things if e.g. it is pointing to a path that an unrelated django directory.

comment:7 by Tim Graham, 11 years ago

Resolution: duplicate
Status: newclosed

Going to close this as a duplicate of #16205 "Beginners install guide for Windows" - I've referenced this ticket there.

Note: See TracTickets for help on using tickets.
Back to Top