python创建Django项目Couldn't import Django解决思路
来源:互联网 发布:股市模拟交易软件下载 编辑:程序博客网 时间:2024/05/16 15:23
最近学习Django,首先就是搭建环境
1起初就是安装过python,版本为2.7
2安装Django,正在python中测试版本成功如下:
Python 2.7.10 (default, Jul 30 2016, 19:40:32)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 11, 2, u'final', 0)
>>>
3 继续创建Django项目,项目名为first
django-admin.py startproject project first
4接着用pycharm打开,给runserver作出配置
5点击运行first项目,遇到import错误(着重敲黑板)如下:
try: import djangoexcept ImportError: raise 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?" )raise这时,我开始查资料,各种百度,没看见什么有效的解决办法。。。
解决思路:
(1)python版本的问题,因为编译器自带了python2.6,尝试换了自己安装的版本
(2)点击运行,又报错,是script parameter的错误(和谐:百度不可靠),发现这个参数原来是如下:
[auth]
changepassword
createsuperuser
[contenttypes]
remove_stale_contenttypes
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
[sessions]
clearsessions
[staticfiles]
collectstatic
findstatic
runserver
结合百度,果断选择runserver.
(3)最后运行结果如下:
System check identified no issues (0 silenced).
You have 13 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.
June 09, 2017 - 03:33:13
Django version 1.11.2, using settings 'project.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
执行成功
- python创建Django项目Couldn't import Django解决思路
- python 创建django项目
- django+python创建第一个web项目
- python django web开发之项目创建
- 【python】Django项目的创建示例
- Django项目实践1 - 创建Django项目
- 使用django创建项目
- 创建django项目
- 创建Django项目
- Eclipse创建Django项目
- 创建django项目
- django创建一个项目
- django 创建项目
- django的创建项目
- Django项目创建例程
- 创建一个django项目
- 创建Django项目
- Django创建项目
- Excel公式-从另一表单通过id列取值列
- 字符串的编码问题详解
- 设计模式之观察者模式
- POJ 1160 Post Office (区间DP+重心)
- redis的数据类型
- python创建Django项目Couldn't import Django解决思路
- Trafodion表物理设计与逻辑设计问答
- HashMap原理分析
- python3小项目——爬取招聘信息(智联招聘)
- Android studio http请求获取数据失败或者获取不到数据原因
- 21 用户进程操作GPIO
- H5+JS+CSS3 实现圣诞情缘--学习心得2
- Java——方法的可变参数
- JDBC操作步骤