安装spyder django后无法正常工作

时间:2019-09-20 04:14:45

标签: django spyder

我在ubuntu系统上安装了spyder,但django无法正常运行。当我运行服务器时显示的错误是

Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    import django
ModuleNotFoundError: No module named 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 17, in <module>
    "Couldn't import Django. Are you sure it's installed and "
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

我既需要OpenCV的spyder,也需要Django。谁能帮忙

2 个答案:

答案 0 :(得分:0)

该错误表示您的系统中缺少Django,如果您已经在virtualenv中安装了依赖项,则需要激活该依赖项,或者只需执行

pip install django --user

如果您有virtualenv,请执行此操作,

Linux

source path/to/venv/bin/activate

Windows

path/to/venv/bin/activate

首先使用以下命令创建虚拟环境

python3 -m virtualenv venv

如果遇到类似Virtualenv module not found的错误提示,则需要通过以下命令使用pip安装virtualenv

pip3 install virtualenv

然后使用上述命令创建虚拟环境。

activate,只需使用

source venv/bin/activate

这将激活虚拟环境。现在,在其上安装Django

pip install django

您不需要指定点子版本(例如pip3),因为虚拟环境是在python3中创建的,因此pip本身默认为pip3

现在终于可以运行服务器了

python manage.py runserver localhost:8080

答案 1 :(得分:0)

做完后就可以了 python3 -m pip安装Django

谢谢萨希尔先生