Mac下python manage.py runsever 报错


macsn@MacsndeMac U_crawler % python manage.py runsever

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?

这个问题纠结我一天,结果打开方式不对,😯  😭  辽~

/***我的错误示范:

出现这个问题,我首先想到Mac下自带python2.7,而我自己安装了一个python3.8,终端执行命令:which python 显示系统自带解析路径,于是我就想怎么把它改成自定义的路径,按照网上各路博客把环境变量bash_profile文件改了一通

but 依然不行,然后我就想一不做二不休,把python2.7删了,只剩下自己装的python3.8总可以了把,按照网上各路博客把删除Mac自带python2.7的终端代码执行了一通,然后macsn@MacsndeMac ~ % which python /usr/bin/python

macsn@MacsndeMac ~ % emmmmmmm 要疯辽 ,这边建议亲不要随便删除Mac自带的python呢,虽然版本低但是它系统对他依赖强啊

**/

正确打开方式:

python3 manage.py runserver
macsn@MacsndeMac U_crawler % python3 manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 17 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.

May 23, 2020 - 02:49:17
Django version 3.0.6, using settings 'U_crawler.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

对加个3就行了,pip指令没法用的时候pip3试试

Django要2.0以上

 

posted @ 2020-05-23 10:57  java从精通到入门  阅读(330)  评论(0编辑  收藏  举报