python常见报错
1,No module named http_client
代码来自:http://www.weiguda.com/blog/18/
没有在虚拟环境测试,直接在当前环境下安装的.最后运行报错.
百度查到:http://blog.csdn.net/prince_jun/article/details/46290097
得知时django和djangorestframework的版本不符导致
我安装djangorestframework是用pip install,而django是以前安装的.
使用'django-admin.py --version'查询,版本时1.6的.网上的都1.7了,重装试下:
$ sudo pip uninstall django
$ sudo pip install django
$ django-admin.py --version
1.8.7
重新运行,无报错
注:后来查询得知本机下载的Django REST framework的版本是3.3.1
$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rest_framework
>>> print rest_framework.__version__
3.3.1
2,ImportError: No module named rest_framework_swagger
解决:$ sudo pip install django-rest-swagger
3,复制代码,运行后报错:no such table: django_session
解决:$ python manage.py syncdb