Virtualenvironment Ubuntu 12 ImportError: No modul

2019-02-25 15:28发布

I can create a project with django-admin.py startproject within a virtualenv. But when I try to run server with python manage.py runserver, I get an error:

(check)robin@robin-VirtualBox:~/checking$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

But I can run the server when I deactivate the environment and run the it from the project directory. Please help how to solve this. Thank you.

(check)robin@robin-VirtualBox:~/checking$ pip freeze
argparse==1.2.1
wsgiref==0.1.2

3条回答
做自己的国王
2楼-- · 2019-02-25 15:50

Maybe the Django has lost some plugin with pip, so we can install Django with Tarball:

  1. Go https://www.djangoproject.com/download/1.6.5/tarball/
  2. Download Django-*.tar.gz
  3. install it.

    $ tar zxvf Django-1.6.5.tar.gz

    $ cd Django-1.6.5/

    $ python setup.py install

查看更多
成全新的幸福
3楼-- · 2019-02-25 15:55

Most likely, you have not installed django in the virtual environment.

  • Either install django in virtual environment. Activate the environment and then install django using pip or other methods.

  • Or link/copy django installed on the system (somewhere in /usr/lib/python-XXX) to python site packages in the environment. No recommended.

查看更多
ら.Afraid
4楼-- · 2019-02-25 16:03

from the output of pip freeze you don't have Django installed in your virtual environment

run pip install django

查看更多
登录 后发表回答