Reputation: 4202
I am trying to install Django on Mac Os X. Following the directions https://docs.djangoproject.com/en/dev/topics/install/#installing-development-version
I created a django.pth in the site-packages directory to the trunk folder. However, for some reason Django seems to only work now if I am INSIDE the trunk folder.
If I am anywhere else, if I run python
and say import django
I get a No module named django
error.
When I try to run django-admin.py
I get a No module named django.core
error.
It works fine if I am inside the trunk directory, if I say Import Django
here,
I can then say print django.get_version()
and it works fine.
Can anyone help?
Thank you.
Upvotes: 4
Views: 2401
Reputation: 4202
I got it work, not sure how though, it might have been just a typo in my path name. Thanks for your help.
Upvotes: 0
Reputation: 21297
Check your installation. Might be you installed in wrong directory. Also check your PYTHONPATH
and sys.path
.
In [4]: import django
In [5]: django
Out[5]: <module 'django' from '/usr/lib/python2.7/site-packages/django/__init__.pyc'>
This shows that django must be in site-packages
then you can import from any where. If you installed it in like /tmp/test/
then add that path in sys.path
to access the django.
Upvotes: 1
Reputation: 174662
Are you sure you installed it for the right version of Python on your system?
A better (more isolated) way is to use a virtual environment:
[~]$ virtualenv --no-site-packages django_env
New python executable in django_env/bin/python
Installing setuptools............done.
[~]$ source django_env/bin/activate
(django_env)[~]$ pip install -e svn+http://code.djangoproject.com/svn/django/trunk/
Obtaining django from svn+http://code.djangoproject.com/svn/django/trunk/
Checking out http://code.djangoproject.com/svn/django/trunk/ to ./django_env/src/django
Running setup.py egg_info for package django
Installing collected packages: django
Running setup.py develop for django
Creating /Users/burhan/django_env/lib/python2.7/site-packages/Django.egg-link (link to .)
Adding Django 1.4b1 to easy-install.pth file
Installing django-admin.py script to /Users/burhan/django_env/bin
Installed /Users/burhan/django_env/src/django
Successfully installed django
Cleaning up...
(django_env)[~]$ python
Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.get_version()
'1.4b1'
[~]$ is the prompt, don't enter this.
Upvotes: 1
Reputation: 14864
print sys.path or PYTHONPATH,
if you see the django path in their you should be able to import it else put it inside sys.path.
Upvotes: 3