mac电脑安装django ,运行django报错解决

报错

(base) wanggangdeMacBook-Pro:django_introduction wanggang$ 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
ModuleNotFoundError: No module named 'django'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    ) from exc
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?
(base) wanggangdeMacBook-Pro:django_introduction wanggang$ 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?
bash: ImportError:: command not found
(base) wanggangdeMacBook-Pro:django_introduction 

解决方式 python3 manage.py runserver


wanggang$ python3 manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).

You have 14 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

April 06, 2019 - 15:36:07
Django version 2.0, using settings 'django_introduction.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

出现原因

电脑安装了两个python ,mac 系统自带的是2.7 ,django 需要的是python3 , 因此需要python3 命令

    原文作者:wg689
    原文地址: https://www.jianshu.com/p/c84562c3244b
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞