ImportError: Couldn‘t import Django. Are you sure it‘s installed and available on your PYTHONPATH en

如果你的django项目出现了此问题,并且搜寻了大量的博客寻求解决并仔细检查过自己的虚拟环境、系统环境之后确定安装了django,却还是出现此问题,那么请往下看:

问题描述

搜了很多博客都说是虚拟环境的问题,百般确认之后确实安装了django并且存在于环境当中,但执行 python manage.py startapp myweb后还是出现以下错误:

File "manage.py", line 22, in
    main()
  File "manage.py", line 13, in main
    raise ImportError(
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?

原因分析:

确定不是环境的问题后,我想那可能是版本的问题。我用的python版本是3.8,django版本是3.25,将django版本降低到3.2后,即可正常运行。下面是查看并更改版本信息:

解决方案:

问题是python版本和Django版本不兼容,需要安装自己对应的Django版本。版本对照表如下链接:(30条消息) Django版本与Python版本兼容对照表_糖冰橙的博客-CSDN博客_django对应的python版本ImportError: Couldn‘t import Django. Are you sure it‘s installed and available on your PYTHONPATH enhttps://blog.csdn.net/tt75281920/article/details/105181305 ;

查看自己的django版本:

pycharm-File-settings-python interpreter

ImportError: Couldn‘t import Django. Are you sure it‘s installed and available on your PYTHONPATH en

双击django,进入Available Packages,点击下面的specify version(指定版本),选择3.2

ImportError: Couldn‘t import Django. Are you sure it‘s installed and available on your PYTHONPATH en

安装完成后打开terminal,重新运行即可。

ImportError: Couldn‘t import Django. Are you sure it‘s installed and available on your PYTHONPATH en

Original: https://blog.csdn.net/qq_50607888/article/details/124481503
Author: 秋欢喜
Title: ImportError: Couldn‘t import Django. Are you sure it‘s installed and available on your PYTHONPATH en

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/813706/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球