Very Simple Program Crashing Python 3.5 and spyder

心不动则不痛 提交于 2019-12-13 07:07:43

问题


xx = 0
n = 4294967295

while xx <= n:
    print("xx = ", xx, bin(xx))
    xx += 1

This results in the following traceback:

  File "<ipython-input-2-0c9d04ddbbc6>", line 1, in <module>
    runfile('C:/Users/Allen/Documents/Python Scripts/crunchy.py', wdir='C:/Users/Allen/Documents/Python Scripts')

  File "C:\Users\Allen\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile
    execfile(filename, namespace)

  File "C:\Users\Allen\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 89, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/Allen/Documents/Python Scripts/crunchy.py", line 11, in <module>
    print("xx = ", xx, bin(xx))

  File "C:\Users\Allen\Anaconda3\lib\site-packages\ipykernel\iostream.py", line 317, in write
    self._buffer.write(string)

ValueError: I/O operation on closed file

回答1:


It seems that you are using ipython.

According to this page: https://github.com/ipython/ipython/issues/9168

you might run into a know issue and will be fixed in the next release. By the way, that program does not crash when I am running it in terminal.




回答2:


(Spyder developer here) This bug is not a Spyder bug but an ipykernel bug. It was fixed in ipykernel version 4.4, released in August 2016.

So please be sure to update to the latest ipykernel by running this command in a terminal (i.e cmd.exe)

conda update ipykernel


来源:https://stackoverflow.com/questions/39176831/very-simple-program-crashing-python-3-5-and-spyder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!