python2.7出现IOError: [Errno 5] Input/output error
来源:互联网 发布:家用健身器材 知乎 编辑:程序博客网 时间:2024/05/22 06:07
以下内容经过各路大神指点,所以属于转载内容:
你会发现,出现这种报错的时候,一定是在print语句地方报这种错。
直接注释掉就行了,但是有很多print就很麻烦了。
还有就是部署web的时候,比如哈,模块A调用了模块B,A是我们运行的Flask,例如
我们使用python A.py &部署,随后,我们又修改了B,但是没有重新部署A,那么这个时候就很容易出现这种报错。
所以每次修改了B以后,A最好重新运行部署下。
后来发现:重新部署flask后,过一段时间还是会出现IO error
python app_modify.py &
改为:
python app8_modify.py > message.log &
或者
python app8_modify.py > /dev/null 2>&1 &
然后,不要直接关闭终端,而是输入exit来关闭终端
据说这么搞的原因是,我们离线部署完终端以后,print语句没地方输出,就error了,所以改为重定向。
终端中出现killed是正常的。
部署flask web框架时可能遇到的问题有:
终端如果出现“Killed”,这个可能是以前关掉的进程,尽管已经关掉了,但是可能会在终端按下回车键以后“回显”
如果终端出现“Exit 1”这个是不正常的,必须解决
另外的4种办法是:
1、用notepad打开所有工程,把所有print全部替换成#print
2、
from __future__ import print_functiondef myprint(msg): passprint=myprintprint("hehehehehe")
此时print结果不会输出到终端
3、
import sysclass MC: def write(*_): passsys.stdout=MC()a=5print "a=",a
此时print结果也不会输出到终端
4、
test.py
import syssys_out = sys.stdoutsys.stdout = open('./test.txt', 'w+')print '...'from test2 import aa()sys.stdout.close()sys.stdout = sys_out
test2.py
def a(): print "sifjo"
test.py和test2.py两个文件放在同一路径下
就可以达到屏蔽test2.py中的输出函数的效果
所以总结下,总共是2种shell 对print的重定向方法+1种notepad暴力替换法+3种python中的处理方法
参考链接:
- python2.7出现IOError: [Errno 5] Input/output error
- [Errno 4] IOError: [Errno 5] Input/output error yum
- 使用tornado运行web程序错误解决方法:IOError: [Errno 5] Input/output error
- 在shell中启动后台执行程序,然后退出shell会引发 IOError [Errno 5] Input/output error
- 使用虚拟机安装Linux出现错误[Errno 5] Input/Output error
- U盘安装Ubuntu系统[Errno 5] Input/output error
- python2.7:IOError: [Errno 2] No such file or directory:
- Linux出现Input/output error
- The installer encountered an error copying files to the hard disk: [Errno 5] Input/output error
- 出现set_locale() failed (5): Input/output error的解决方法
- 操作串口时,出现Input/output error
- win10上用Python2.7处理文本,出错IOError: [Errno 2] No such file or directory:如何解决???
- sshfs Input/output error
- linux input/output error
- 解决ubuntu挂载NTFS磁盘时出现input/output error
- 解决ubuntu挂载NTFS磁盘时出现input/output error
- 安装python包时出现IOError: [Errno 13] Permission denied
- fatal error: input/output error
- chrome文件上传 /获取文件路径c:/fakepath的解决办法
- 深度学习第一课 第四周 深层神经网络用python的实现
- leetcode 446. Arithmetic Slices II
- malloc、free、calloc、realloc的介绍
- maven-assembly-plugin 入门指南
- python2.7出现IOError: [Errno 5] Input/output error
- 最长公共子串问题 动态规划
- xgboost 用法讲解
- 2017-12-9
- 蓝桥杯训练:开灯游戏
- CCSv7使用指南连载4:Uniflash使用指南
- vbox虚拟机装centOS教程链接,以及自己搭建过程中遇到的一些坑
- 自适应控制---模型参考自适应控制(一)基于局部参数最优化的设计方法(MIT方案)
- Android Notification 你应该知道的事