Tutorial :Django installation problem on Windows



Question:

I am trying to install Django on Windows XP. Here is what I did:

(1) Downloaded and installed Python 2.7 from

http://python.org/ftp/python/2.7/python-2.7.msi

in C:\Python27


(2) Downloaded Django 1.2.1 from

http://www.djangoproject.com/download/1.2.1/tarball/


(3). After unzipping the file I placed Django's folder inside Python's site packages folder as below:

C:\Python27\Lib\site-packages\Django-1.2.1


(4). Now when I try to run "setup.py" in Django folder, I get the following error:

Traceback (most recent call last):    File "C:\Python27\Lib\site-packages\Django-1.2.1\setup.py", line 48, in <module>      root_dir = os.path.dirname(__file__)  NameError: name '__file__' is not defined  

Screenshot can be seen below: alt text

What am I doing wrong?

Thanks


Solution:1

Alternative method

  1. Install easy_install : http://pypi.python.org/pypi/setuptools
  2. Add C:\Python27\Scripts to your system path
  3. Open a command line and enter easy_install django.

This will pull the latest version of Django off the PyPI website, and install it in that directory.

easy_install is definitely my favorite method for installing python modules.


Solution:2

Delete C:\Python27\Lib\site-packages\Django-1.2.1

Unzip tarball anywhere you want, then copy "django" subfolder from unpacked tarball into c:\Python27\lib\site-packages\, and you're done. You don't need to run setup.py actually.

If you want to install using setup.py, then open your command shell (press Win+R, type "cmd" and press Enter), change into dir you unpacked archive to (e.g. c:\archive\Django-1.2.1), and run "C:\Python27\python.exe setup.py install" without quotes.

Important note: you must run command shell with administrator privileges.


Solution:3

An alternate all-in-one open source Windows installer for Django that installs Apache, Python, etc.: Djangostack


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »