views:

41

answers:

1

Here's my problem. I have a mac with 2.5 installed & was using django 1.1 with it. I had no problems until I decided to upgrade python & django. I uninstalled django from my mac as per the djangoproject.com website recommends. I left python 2.5 on my mac as not to interfere with pre-installed mac programs. I put python 2.6 & 3.1 on my mac via mac ports. Python boots up fine in my mac & I can switch between versions very easily via terminal. I put django on my mac. This is where it's installed:

/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/bin/django-admin.py.

Python 2.6 is also set as python_select python26, python_select -s via macports terminal commands, Which makes it the system start up for python. I have absolutely no problem with python, it runs perfectly. When I go into the python2.6 interpreter & issue import django- print django.VERSION, I get 1, 2, 1, 'final', 0). So there should be a sym-link created for the latter. When I go to create a django-project from my system project folder via terminal, I keep getting this:

demetrius-fords-macbook-pro-17:django_projects demet8$ django-admin.py startproject demo 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 tried everything from creating my own sim-link manually to other install solutions for django and I cannot create a django project from a system command of django-admin.py, nor can I test the installation version via $ django-admin.py --version. I can only check the django version from the interpreter as I stated earlier. Any suggestions? I am out of answers & frustrated @ this point!

A: 

Most likely you have more than one version of Django installed; note the path (/usr/local/bin/django-admin.py) in the error message. You may also not have your PATH environment variable set up correctly so that the MacPorts paths appear before /usr/local/bin (where you may have a link to a python.org python) and /usr/bin (where the Apple-supplied python is). Your PATH should like something like this:

$ echo $PATH
/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin:/opt/local/bin:/usr/local/bin:/usr/bin:/bin # and so forth

If not, you should modify the appropriate shell startup script, probably .bash_profile, to modify PATH permanently.

You can test whether it works by explicitly invoking the script with the MacPorts python:

$ /opt/local/bin/python2.6 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/bin/django-admin.py
Ned Deily
I have suggest using *virtualenv* in *demet8* other question exactly for that, avoiding this kind of problem, messing with the `PATH`. With *virtualenv* you can have as many Django installations as you like without any problems (and is't true for any python package or module). It's very flexible. If you need to work on many python projects at the same time, it's a must.
Etienne
virtualenv is great and I often recommend using it. But, in this case, the OP is using MacPorts and to use *any* of the ports it provides you need to get the basics right like setting `PATH`. And, again, OS X is a bit of a different animal when it comes to multiple Python instances.
Ned Deily
demet8