import winshell
r = list(winshell.recycle_bin())
for index, value in enumerate(r):
print(index, value.original_filename())
This is the simple script I wrote, but when I try running it (or antyhing else that uses winshell) I get this error:
ModuleNotFoundError: No module named 'win32'
And when I try running pip install win32
I get another error:
ERROR: Could not find a version that satisfies the requirement win32 (from versions: none)
ERROR: No matching distribution found for win32
So now I'm even more confused. Why does winshell need a different module? That module doesn't even exist. Is it fine if I use some different module than the non-existent win32? If so which one? What am I supposed to do now?
First, you have to execute the script inside the Scripts directory, the pywin32_postinstall.py. Let’s say your Python directory is C:\python3, just follow the code below.
After that, the installation will drop the DLL files under the
C:\Windows\System32
. You need to move those two files ( pythoncom310.dll and pywintypes310.dll) toC:\python3\Lib\site-packages\win32
directory.After that, you need to edit the python310._pth that you can find inside the Python installation folder. Then make the following changes:
Save and try running your code again.
If you still get an error saying “ImportError: DLL load failed while importing win32api: The specified module could not be found.”, make sure you have copied the two dll files to
Lib\site-packages\win32 directory
. PythonWin32Api