简体   繁体   English

I/O 错误:文件描述符错误,无法保存 python 文件

[英]I/O Error: Bad File Descriptor, can not save python file

I recently uninstalled and reinstalled python, and i have not been able to save one of my programs since.我最近卸载并重新安装了 python,从那以后我一直无法保存我的程序之一。

When i hit ctrl+S, IDLE throws me a window saying I/O Error: Bad file descriptor .当我按下 ctrl+S 时,IDLE 会向我抛出一个窗口,上面写着I/O Error: Bad file descriptor I can not even save my file!我什至无法保存我的文件!

As it turns out i don't think it has anything to do with the actual code.事实证明,我认为它与实际代码没有任何关系。 No matter what is in the program, it still throws this error when i try to save, unless there is no code whatsoever!无论程序中有什么,当我尝试保存时它仍然会抛出此错误,除非没有任何代码!

IF anyone knows why this error is occurring, please tell me or post an updated version of the code, any help is appreciated如果有人知道为什么会发生此错误,请告诉我或发布代码的更新版本,感谢您的帮助

I am using Windows 10, Python 3.7.3 64-bit [a couple days ago i uninstalled (just through windows settings) 32-bit and installed 64 from the python website]我正在使用 Windows 10,Python 3.7.3 64 位 [几天前我卸载了(仅通过 Windows 设置)32 位并从 python 网站安装了 64]

In Windows, it is theorically possible to install 32 bits and 64 bits versions of Python side by side, and it should work with a genuine installation.在 Windows 中,理论上可以并排安装 32 位和 64 位版本的 Python,并且它应该可以与正版安装一起使用。 But dragons are waiting around:但是龙正在等待:

  • it is possible to have shortcuts pointing to a wrong location.可能会有指向错误位置的快捷方式。
  • if the PATH has been changed to allow direct usage of the python , or pip command from the command line, risk is that you use the wrong tool如果 PATH 已更改为允许从命令行直接使用pythonpip命令,则风险是您使用了错误的工具
  • if any Python environment variable has been set, problems are almost guaranteed如果设置了任何 Python 环境变量,几乎可以保证出现问题

Furthermore, Python can be installed either for the current user or for all users, which adds more possibilities for inconsistancies.此外,Python 可以为当前用户或所有用户安装,这增加了更多不一致的可能性。

Once an installation is deemed broken, uninstalling one of the versions is generally useless on can even cause more problems.一旦安装被认为损坏,卸载其中一个版本通常是无用的,甚至会导致更多问题。 Long story short, if you have entered the world of inconsistancy, you must clean up everything.长话短说,如果你进入了不一致的世界,你必须清理一切。

My advice here is:我的建议是:

  • find where the Python versions were installed and note it找到 Python 版本的安装位置并记下它
  • find if additional tools ( py ) have been installed and try to find which ones查找是否安装了其他工具( py )并尝试查找哪些
  • uninstall every Python version卸载每个 Python 版本
  • control that the installation paths are empty控制安装路径为空
  • search the environment and PATH for any Python related information and remove them在环境和 PATH 中搜索任何与 Python 相关的信息并将其删除

When everything looks good, reinstall from the installation wizard.当一切正常时,从安装向导重新安装。

Hopefully it should work.希望它应该工作。 If it does not I cannot help: despite being presented as an end user friendly system, Windows is a very feature rich and complex OS and trying to fully analyze a Windows system is beyond the capacity of most users, including most power users and sysadmins.如果没有,我也无能为力:尽管 Windows 是一个对最终用户友好的系统,但它是一个功能非常丰富且复杂的操作系统,尝试全面分析 Windows 系统超出了大多数用户的能力,包括大多数高级用户和系统管理员。 At a point, the only possibility left is to reinstall the full OS and then cleanly install everything back... when it is possible...在某一点上,唯一剩下的可能是重新安装完整的操作系统,然后重新安装所有东西......如果可能......

I have experienced the same issue.我也遇到过同样的问题。 In my case the Windows 10 Defender was the root cause.就我而言,Windows 10 Defender 是根本原因。 I added in Windows Defender Ransomware Protection the python.exe of my used IDE and the issue disappears.我在 Windows Defender Ransomware Protection 中添加了我使用过的 IDE 的 python.exe,问题消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM