Import Error Django 1.4 and Virtualenv on Ubuntu

Anonymous avatarAnonymous created an issue

While trying to make html on my Ubuntu server I get an import error. Error, error traceback and double check that I'm in virtualenv and can import django.

Building fails with error:

(django)admin@ububtu:/srv/company$ sudo make html
sphinx-build -b html -d _build/doctrees   . _build/html
Running Sphinx v1.1.3

Exception occurred:
  File "/srv/company/conf.py", line 18, in <module>
    from django.core.management import setup_environ
ImportError: No module named django.core.management
The full traceback has been saved in /tmp/sphinx-err-fupgf1.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-dev/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
make: *** [html] Error 1

Error Detail:

(django)admin@ubuntu:/srv/company$ sudo cat /tmp/sphinx-err-fupgf1.log
# Sphinx version: 1.1.3
# Python version: 2.7.3
# Docutils version: 0.10 release
# Jinja2 version: 2.6
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/sphinx/cmdline.py", line 188, in main
    warningiserror, tags)
  File "/usr/local/lib/python2.7/dist-packages/sphinx/application.py", line 102, in __init__
    confoverrides or {}, self.tags)
  File "/usr/local/lib/python2.7/dist-packages/sphinx/config.py", line 216, in __init__
    exec code in config
  File "/srv/company/conf.py", line 18, in <module>
    from django.core.management import setup_environ
ImportError: No module named django.core.management

Make sure we can import django:

(django)admin@ubuntu:/srv/company$ python
Python 2.7.3 (default, Aug  1 2012, 05:16:07) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django
<module 'django' from '/home/admin/.virtualenvs/django/local/lib/python2.7/site-packages/django/__init__.pyc'>
>>> 

Comments (3)

  1. Takayuki Shimizukawa
    • edited description

    I could not reproduce the reported problem.

    $ cat /etc/lsb-release 
    DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=12.04
    DISTRIB_CODENAME=precise
    DISTRIB_DESCRIPTION="Ubuntu 12.04.1 LTS"
    $ virtualenv --distribute django
    $ cd django
    $ source bin/activate
    (django)$ pip install sphinx django
    (django)$ django-admin.py startproject django
    (django)$ cd django
    (django)$ sphinx-quickstart doc
    Welcome to the Sphinx 1.1.3 quickstart utility.
    -snip-
    Finished: An initial directory structure has been created.
    -snip-
    (django)$ cd doc
    (django)$ echo "from django.core.management import setup_environ" >> conf.py
    (django)$ make html
    sphinx-build -b html -d _build/doctrees   . _build/html
    Making output directory...
    Running Sphinx v1.1.3
    -snip-
    Build finished. The HTML pages are in _build/html.
    (django)$ make clean
    rm -rf _build/*
    (django)$ sudo make html
    sphinx-build -b html -d _build/doctrees   . _build/html
    Making output directory...
    Running Sphinx v1.1.3
    -snip-
    Build finished. The HTML pages are in _build/html.
    (django)$ 
    

    BTW, why did you do 'sudo make html' instead of 'make html' ?

  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.