[英]How to let the python script (abc.py) keep executing on AWS even after Connection lost or SSH connection is terminated?
[英]Why can a Python script file not be named abc.py?
一天在 PyCharm 中搞亂 Python 的時候,遇到了一個很傻的問題。 也就是說,當我嘗試在名為abc.py
的文件中運行一個簡單腳本時,我收到一個錯誤。 我嘗試直接從終端運行相同的文件,它看起來不錯。
abc.py
print("Hello world")
Output:
/Users/.../venv/bin/python /Users/.../abc.py
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/io.py", line 52, in <module>
File "/Users/.../abc.py", line 1, in <module>
RuntimeError: lost sys.stdout
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
只是出於好奇,這是怎么回事?
編輯:為什么它只發生在從 PyCharm 運行時,而不是從終端運行時?
abc
是 python 的標准模塊。 這里=> https://docs.python.org/3/library/abc.html
如果您將自己的模塊 abc.py 重命名為 abcd.py 之類的其他名稱,它應該可以工作
因為 python 被混淆了,所以您會收到一個錯誤。
您看,python 中有一個內置模塊,也稱為abc (“抽象基類”的縮寫)!
我建議您將文件命名為其他名稱,或者其他瘋狂的方式,刪除模塊(開個玩笑,不要那樣做。)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.