Python 入门级报错处理
问题1:Missing parentheses in call to 'print'
原因:因为Python2.X和Python3.X不兼容。
我安装的是Python3.X,但是我试图运行的却是Python2.X 的代码。
所以上面的语法在python3中是错误的。在python3中,你需要将print后面的语句加括号,正确的写法:
print ("hello world")
问题2:创建项目报错,django-admin startproject sundyblog
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\django\utils\html.py", line 16, in <module>
from .html_parser import HTMLParser, HTMLParseError
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\django\utils\html_parser.py", line 12, in <module>
HTMLParseError = _html_parser.HTMLParseError
AttributeError: module 'html.parser' has no attribute 'HTMLParseError'
原因:HTMLParseError在pythons3.5已经没有了
解决方法:
方法1:将python版本回退到3.3或3.4
方法2:升级django版本
>pip3 install django==1.8 ##升级django版本
C:\Users\andy>django-admin startproject sundyblog ##再次执行,无报错
问题3: 使用 ImageField 字段建表报错
C:\Users\andy\sundyblog>python manage.py makemigrations
SystemCheckError: System check identified some issues:
ERRORS:
blog.Article.portal: (fields.E210) Cannot use ImageField because Pillow is not installed.
HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip install Pillow".
解决:C:\Users\andy\sundyblog>pip install -i https://pypi.douban.com/simple/ Pillow
Looking in indexes: https://pypi.douban.com/simple/
Collecting Pillow
Downloading https://pypi.doubanio.com/packages/0f/fe/0979c8d6fa0c986e4603e5396904945b44f93ff9e346ee5ffadc7487cff6/Pillow-5.4.1-cp35-cp35m-win32.whl
100% |████████████████████████████████| 1.7MB 351kB/s
Installing collected packages: Pillow
Successfully installed Pillow-5.4.1
You are using pip version 19.0.1, however version 19.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
C:\Users\andy\sundyblog>python manage.py makemigrations
Migrations for 'blog':
0001_initial.py:
- Create model Article
- Create model Author
- Add field autor to article
C:\Users\andy\sundyblog>
Python 入门级报错处理的更多相关文章
- mac 上python编译报错No module named MySQLdb
mac 上python编译报错No module named MySQLdb You installed python You did brew install mysql You did expor ...
- 调用python脚本报错/usr/bin/env: python : No such file or directory
一.调用python脚本报错 /usr/bin/env: python: No such file or directory 二.解决方法 原因是在windows上编写的脚本,使用dos2unix对脚 ...
- 第一次打开pycharm运行python文件报错”No Python interpreter selected“问题的解决办法
前面没有细讲,这里细述一下安装pycharm后,第一次打开pycharm运行python文件报错"No Python interpreter selected"问题的解决办法. 出 ...
- python运行报错:urllib2.URLError: <urlopen error [Errno 10061] >
Traceback (most recent call last): File "F:\adt-bundle-windows-x86_64-20140702\eclipse\workspac ...
- [Error]Python虚拟环境报错 OSError: setuptools pip wheel failed with error code 2
mkvirtualenv py35 python新建虚拟环境报错,setuptools pip wheel failed with error code 2 刚好昨天在CentOS安装的时候也总是报s ...
- win7 64位 python启动报错:无法启动此程序,因为计算机中丢失api-ms-win-crt-process-l1-1-0.dll
安装python3.7,安装成功后,在cmd窗口输入python检查是否安装成功,报错:无法启动此程序,因为计算机中丢失api-ms-win-crt-process-l1-1-0.dll 在网上查询了 ...
- 【转】【Python】Python 中文编码报错
用 Python 输出 "Hello, World!",英文没有问题,但是如果你输出中文字符"你好,世界"就有可能会碰到中文编码问题. Python 文件中如果 ...
- python webdriver 报错WebDriverException: Message: can't access dead object的原因(pycharm中)
PyCharm中运行firefox webdriver访问邮箱添加通讯录的时候报错-WebDriverException: Message: can't access dead object 调了半天 ...
- python实践报错:SyntaxError: Non-ASCII character
报错: File "C:\001myWorkspace\001myWork\workspace2\MyFirstPython\src\demo4\demo4-2.py", line ...
随机推荐
- 【Shell】单行注释和多行注释
单行注释 '# ' # echo "hello" 多行注释 方法1 : << ! 这是注释1 这是注释2 这是注释3 ! 方法2 :' 这是注释1 这是注释2 这是注释 ...
- MySQL数据库语句
一 . 常用mysql命令行命令 1 .启动MYSQL服务 net start mysql 停止MYSQL服务 net stop mysql 2 . netstat –na | ...
- css清除浮动方式总结
1.通过父元素overflow:hidden,缺点:超出部分隐藏,不推荐使用 <!DOCTYPE html> <html lang="en"> <he ...
- Hacklab综合关
没有注入到底能不能绕过登录 分值: 350 不是SQL注入 通关地址 不是注入,就先扫一下后台,发现在robots.txt后面有 访问一下,发现要先登陆,用burpsuit爆了好久都没有成功,最后 ...
- mysql 按类别之用一条SQL语句查询出每个班前10名学生数据
select * from 学生信息表 a where 10 > (select count(*) from 学生信息表 where 班级ID = a.班级ID and 班内名次 > a ...
- 18-09-13 机器人和服务器之间的ip配置和脚本的重启
问题9 服务器安装完毕后 怎么配置机器人客户端的配置ip
- TCP学习总结(三)
TCP的流量控制 1.利用滑动窗口实现流量控制 所谓流量控制,就是让发送方的发送速率不要太快,要让接收方来得及接收.利用下图来说明如何利用滑动窗口机制进行流量控制: 一开始(connect后),B告诉 ...
- CSS内嵌样式实现打字效果
<style> *{margin:0;padding:0;} @keyframes typing { from { width: 0; } } @keyframes blink-caret ...
- 最新工控\建模仿真\组态\监控集成开发平台源码解决方案2019 ---所有VC++源码100%提供!
使用E-Form++可视化企业版本,构建属于自己的专业工控.建模仿真. 监控组态.培训仿真平台! -- 100%源码 (全部采用VC++/MFC编写,支持.NET, Java, Web, Delphi ...
- 5--Postman上传文件
请求: charles抓到请求信息: request: --21b63bd3-1543-46cf-ab25-eaa5adf82688Content-Disposition: form-data; na ...