0

I recently installed Python 2.7 and django 1.4.1 on a Linux machine. I thought the install went successfully, however, when I try and run the command: django-admin.py startproject newproject, I get the following message:

andrew@server [~/django]# django-admin.py startproject newproject
Traceback (most recent call last):
  File "/usr/local/bin/django-admin.py", line 2, in ?
    from django.core import management
ImportError: No module named django.core

I have found a few similar questions, but none seemed to fix the issue. When I open python through the shell and import django, it works, so I'm not sure what to do.

Thanks!

3
  • Check which django-admin.py you are executing.
    – Rohan
    Oct 5, 2012 at 7:04
  • Once you find it, also check whether the #! line of it lists the same python executable you're running in your shell.
    – dokkaebi
    Oct 5, 2012 at 7:22
  • try this: 1)import django 2)dajngo.__file__. After this check core exist there or not. Oct 5, 2012 at 9:16

2 Answers 2

0

I would recommend issuing the following from a Python prompt:

import site
print site.getsitepackages()[1]

This will provide you with the path where your site-packages live. This directory would be the first place I would assume your django installation to have been placed. Or you can issue the following at a command prompt:

ls `python -c "import site; print site.getsitepackages()[1]"`

If you do not find your django installation in the above directory you can:

  1. Reinstall django and ensure it ends up where you expect
  2. Continue searching the paths used by Python

If you decide to continue searching for your installation you can inspect sys.paths and look through the list of paths to determine if django was installed in one of these paths.

Lastly, you could have potentially installed django in your "user" site-packages. This would be done by including --user when you ran setup.py. If you did this you can find your user site-packages issuing the following from a Python prompt:

import site
print site.getusersitepackages()
0

I was having the same issue ..

The first change I made was to set an alias so that python 2.5 is used. The second was to move /Library/Python/2.5/site-packages to the beginning of PYTHONPATH. I made these changes by adding two lines to my .profile:

export PYTHONPATH="/Library/Python/2.5/site-packages:$PYTHONPATH" alias python=python2.5

1
  • OP is using Linux instead of OSX, he might not be able to find such paths.
    – okm
    Oct 5, 2012 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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