pywin32 icon indicating copy to clipboard operation
pywin32 copied to clipboard

pywin32_postinstall.py fails (DLL load failure) with Microsoft Store's Python

Open NathanZook opened this issue 6 years ago • 10 comments

Running Windows 10 in a VM. Python 3.7.4 installed from App Store.

As administrator:

pip install pywin32 Downloading https://files.pythonhosted.org/packages/a3/8a/eada1e7990202cd27e58eca2a278c344fef190759bbdc8f8f0eb6abeca9c/pywin32-224-cp37-cp37m-win_amd64.whl (9.0MB) 100% |████████████████████████████████| 9.1MB 2.8MB/s Installing collected packages: pywin32 Successfully installed pywin32-224 You are using pip version 19.0.3, however version 19.2.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.

python pywin32_postinstall.py -install pywin32_postinstall.py:156: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp Traceback (most recent call last): File "pywin32_postinstall.py", line 605, in install() File "pywin32_postinstall.py", line 328, in install LoadSystemModule(lib_dir, "pywintypes") File "pywin32_postinstall.py", line 166, in LoadSystemModule mod = imp.load_dynamic(modname, filename) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1264.0_x64__qbz5n2kfra8p0\lib\imp.py", line 342, in load_dynamic return _load(spec) File "", line 696, in _load File "", line 670, in _load_unlocked File "", line 583, in module_from_spec File "", line 1043, in create_module File "", line 219, in _call_with_frames_removed ImportError: DLL load failed: The specified module could not be found.

Note: there is a space in my user name. Is it possible that this is an issue?

NathanZook avatar Aug 01 '19 22:08 NathanZook

I doubt the space in the name is an issue, and I can't think of what might be going wrong. My best guess is that the version from the app store is laid out slightly differently - I'll try and test this ASAP.

mhammond avatar Aug 02 '19 00:08 mhammond

I can imagine that the problem is solved when applying the corrections I made to get the CI tests working. @mhammond Guess we need to find some time to discuss how to merge my efforts. I think email will be best again. How about continuing our last conversation? 😃

thopiekar avatar Aug 26 '19 18:08 thopiekar

Sorry for the delay, but I was away last week with work (chewing 2 weekends!) and am away this weekend for family - but I will get back to all of this as I can!

mhammond avatar Aug 27 '19 02:08 mhammond

I had an issue installing the xlwings addin, until I figured out the DLL error issue I was experiencing is related to this issue. I also have installed Python 3.7.4 from App Store.

nk00li avatar Sep 27 '19 07:09 nk00li

I have the exact same issue, did anyone find a solution?

This is my terminal Output, when using a Conda Env installed in a separate 'Z' Drive:

(tfdeeplearning) C:\Users\harsh\Documents\6th Sem\Coursera Udemy\Data Science and ML Visualization>python C:\Users\harsh\AppData\Roaming\Python\Python35\Scripts\pywin32_postinstall.py -install Parsed arguments are: Namespace(destination='Z:\\Anaconda\\envs\\tfdeeplearning\\Lib\\site-packages', install=True, quiet=False, remove=False, silent=False, wait=None) Traceback (most recent call last): File "C:\Users\harsh\AppData\Roaming\Python\Python35\Scripts\pywin32_postinstall.py", line 633, in <module> install(args.destination) File "C:\Users\harsh\AppData\Roaming\Python\Python35\Scripts\pywin32_postinstall.py", line 334, in install LoadSystemModule(lib_dir, "pywintypes") File "C:\Users\harsh\AppData\Roaming\Python\Python35\Scripts\pywin32_postinstall.py", line 174, in LoadSystemModule mod = imp.load_dynamic(modname, filename) File "Z:\Anaconda\envs\tfdeeplearning\lib\imp.py", line 343, in load_dynamic return _load(spec) File "<frozen importlib._bootstrap>", line 693, in _load File "<frozen importlib._bootstrap>", line 666, in _load_unlocked File "<frozen importlib._bootstrap>", line 577, in module_from_spec File "<frozen importlib._bootstrap_external>", line 938, in create_module File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed ImportError: DLL load failed: The specified module could not be found.

buckyball99 avatar May 24 '20 13:05 buckyball99

There is almost certainly a dupe of pywintypes35.dll and that's being loaded instead of the expected one.

mhammond avatar May 25 '20 01:05 mhammond

Yep, same issue here (can't complete the post install). Had a look round for duplicate pywintypes files and couldn't find any. Is there anywhere these would be normally?

I also got Python from the windows app store. I might try another version as a troubleshoot soon.

nilch avatar Jul 26 '20 08:07 nilch

Yep installing from here https://www.python.org/downloads/ works for me.

nilch avatar Jul 30 '20 07:07 nilch

Can confirm this issue is still happening today (2023) with Python 3.11.5. Running the post-installer fails similarly if you installed Python from the Microsoft app store but succeeds if you use the binary installer at http://python.org/getit/windows.

wescpy avatar Sep 30 '23 05:09 wescpy

@wescpy @nk00li Which version of pywin32 are you using? And how did you install it? (pip install vs standalone .exe)


Since 71afa71e11e6631be611ca5cb57cda526b5e91ab, the PATH is now prepended, rather than appended. For Python >= 3.8, the PATH environment variable isn't even used. This is included in pywin32==226.

Python 3.7 has also reached EOL (meaning no security fixes/support) and I'd recommend migrating over to 3.8+ (see #2207)

.exe installers are now deprecated #1939, so you should install from PyPI (ie: pip install pywin32>=226)

Given the sheer amount of "ImportError: DLL load failed: The specified module could not be found." issue duplication and old history, I'd like to consolidate the current state of these issues.

Now there's an additional detail from this specific thread that the Python install from the Microsoft App store seems to be causing issues over a regular install, making even the postinstall script fail.

Avasam avatar Mar 17 '24 20:03 Avasam