Search code examples
pythonpython-3.xfilepython-idle

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.

When i hit ctrl+S, IDLE throws me a window saying 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]


Solution

  • 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. 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
    • if any Python environment variable has been set, problems are almost guaranteed

    Furthermore, Python can be installed either for the current user or for all users, which adds more possibilities for inconsistancies.

    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
    • find if additional tools (py) have been installed and try to find which ones
    • uninstall every Python version
    • control that the installation paths are empty
    • search the environment and PATH for any Python related information and remove them

    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. At a point, the only possibility left is to reinstall the full OS and then cleanly install everything back... when it is possible...