'How to restore a changed native python file?

I have accidentally overwritten a native python file (Python\Python310\Lib\wave.py). I cant restore it through Windows.

Is there a clever way to restore it? I was thinking to reinstall Python, but Im afraid that I might need to reinstall all my packages, which would be a pain. Are there other options?



Solution 1:[1]

Fixed by finding the native Python source code through https://docs.python.org/3/py-modindex.html.

Solution 2:[2]

I would recommed you to reinstall or repair Python.

Repair Python

And to ease your pain from reinstalling the modules, you can use the below to save all modules names with version.

pip freeze >a.txt

Then after reinstalling use

pip install -r a.txt

This would install all the module in the text. For more detail you can use pip install -help

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jnz
Solution 2 Faraaz Kurawle