今天在创建一个Django项目的时候,使用命令行,进入项目目录运行:
python manage.py runserver
然后报错
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?
百度之后,很多解决方案,
conda env list
# conda environments:
#
base * D:\Anaconda
mysite D:\Anaconda\envs\mysite
utial D:\Anaconda\envs\utial
zhaopin_spider D:\Anaconda\envs\zhaopin_spider
activate mysite
(mysite) D:\pyWorkspace\mysite>python 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 04, 2019 - 08:47:28
Django version 2.2, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
出现类似的缺少包的问题,而包明明已经导入的时候,我猜测就是环境,或者路径的问题,原理都是相通的,在谷歌百度问题的时候,也应该多思考,很多时候可以根据别人的解决方案获得灵感。要带着脑子去找解决问题。
参考博文:
https://blog.csdn.net/weixin_42292991/article/details/86520277
https://blog.csdn.net/virusll/article/details/79437755