简体   繁体   中英

How can I completely reinstall Django on a Mac

I'm a complete newcomer to Python and the Django framework so please be gentle.

I'm on a Mac 10.8 and MAMP. I was following the tutorial and installed the latest stable version (1.5) of Django using pip thanks to the instructions on this page. For some reason, I decided immediately after this to install instead the development version (1.6dev) by cloning the git repository using these instructions. At this point, everything was OK and running the following code:

>>> import django
>>> print(django.get_version())

printed out version 1.6dev-blahblahblah.

I then tried to create my first project with this command:

django-admin.py startproject mysite

It worked. Here's where I did something stupid. I changed my mind at this point and thought it might be better to stick with the stable development version rather than the bleeding edge version and so I tried to remove the development version. All I did was delete the django folder found after typing this command:

python -c "import sys; sys.path = sys.path[1:]; import django; print(django.__path__)"

I then reran pip and it said everything was installed correctly. When I get the version number from the Python interpreter I get this output:

>>> import django
>>> print(django.get_version())
1.5.1

However, when I try to create a new project I get the following error:

django-admin.py startproject mysite
Traceback (most recent call last):
File "/usr/local/bin/django-admin.py", line 4, in <module>
from pkg_resources import require; require('Django==1.6.dev20130425172216')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2607, in <module>
parse_requirements(__requires__), Environment()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: Django==1.6.dev20130425172216
Garrys-MacBook-Air-2:~ Garry$ 

Sorry for being stupid but how can I fix this??

Thanks

File "/usr/local/bin/django-admin.py", line 4, in <module>
from pkg_resources import require; require('Django==1.6.dev20130425172216')

It looks like the django-admin.py is still the one from version 1.6blabla I would try to uninistall everything via pip (1.5 and/or 1.6), make sure /usr/local/bin/django-admin.py was also removed, and reinstall 1.5 via pip again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM