Problems installing Django There is no module named django.core

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 django.pth in the site-packages directory in the trunk folder. However, for some reason, Django seems to work only now if I INSIDE the trunk folder.

If I'm somewhere 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 .

It works fine if I get to the trunk directory, if I say import django here,

Then I can say print django.get_version() and it works fine.

Can anyone help?

Thanks.

+4
source share
4 answers

print sys.path or PYTHONPATH,

if you see the django path in them, you should be able to import it, otherwise put it in sys.path.

+3
source

Are you sure you installed it for the correct 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 an invitation, do not enter it.

+1
source

Check installation. You may have been installed in the 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 should be in site-packages , after which you can import from anywhere. If you installed it as /tmp/test/ , add this path to sys.path to access django.

+1
source

I earned it, but I'm not sure that although it might have been just a typo in my path name. Thank you for your help.

0
source

Source: https://habr.com/ru/post/1397950/


All Articles