Fixing hg.exe “ImportError: DLL load failed: %1 is not a valid Win32 application.”
Posted by jpluimers on 2021/07/21
If you get the below error when running hg.exe
, then you are mixing a 64-bit Mercurial with 32-bit dependencies:
C:\>hg --version Traceback (most recent call last): File "hg", line 43, in File "hgdemandimport\demandimportpy2.pyc", line 150, in __getattr__ File "hgdemandimport\demandimportpy2.pyc", line 94, in _load File "hgdemandimport\demandimportpy2.pyc", line 43, in _hgextimport File "mercurial\dispatch.pyc", line 22, in File "hgdemandimport\demandimportpy2.pyc", line 248, in _demandimport File "hgdemandimport\demandimportpy2.pyc", line 43, in _hgextimport File "mercurial\i18n.pyc", line 28, in File "hgdemandimport\demandimportpy2.pyc", line 150, in __getattr__ File "hgdemandimport\demandimportpy2.pyc", line 94, in _load File "hgdemandimport\demandimportpy2.pyc", line 43, in _hgextimport File "mercurial\encoding.pyc", line 24, in File "mercurial\policy.pyc", line 101, in importmod File "mercurial\policy.pyc", line 63, in _importfrom File "hgdemandimport\demandimportpy2.pyc", line 164, in __doc__ File "hgdemandimport\demandimportpy2.pyc", line 94, in _load File "hgdemandimport\demandimportpy2.pyc", line 43, in _hgextimport File "mercurial\cext\parsers.pyc", line 12, in File "mercurial\cext\parsers.pyc", line 10, in __load ImportError: DLL load failed: %1 is geen geldige Win32-toepassing.
The equivalent English error is [WayBack] “ImportError: DLL load failed: %1 is not a valid Win32 application.
” – Google Search.
The problem is the bitness of hg.exe
: [WayBack] python – Error while installing Mercurial on IIS7 64bit: “DLL Load Failed: %1 is not a valid Win32 application” – Stack Overflow
You can quickly figure out the bitness of hg.exe
:
C:\>where hg C:\Program Files\Mercurial\hg.exe C:\>sigcheck "C:\Program Files\Mercurial\hg.exe" Sigcheck v2.72 - File version and signature viewer Copyright (C) 2004-2019 Mark Russinovich Sysinternals - www.sysinternals.com c:\program files\mercurial\hg.exe: Verified: Unsigned Link date: 17:49 9-7-2019 Publisher: n/a Company: n/a Description: Fast scalable distributed SCM (revision control, version control) system Product: mercurial Prod version: 5.0.2 File version: 5.0.2 MachineType: 64-bit
Forcing x86 of Mercurial
Since I use chocolatey for most my installs, I forced x86
the Chocolatey way:
- [WayBack] CommandsInstall · chocolatey/choco Wiki · GitHub: Options and Switches
- [WayBack] CommandsInstall · chocolatey/choco Wiki · GitHub: Default Options and Switches
- [WayBack] chocolatey – How to choose between 32 bit or 64 bit version of a package? – Super User
I was missing the
forcex86
switch:--x86, --forcex86 ForceX86 - Force x86 (32bit) installation on 64 bit systems. Defaults to false.
So after these:
choco uninstall --yes hg choco install --yes --force86 hg
I got this signature check:
C:\>sigcheck "C:\Program Files (x86)\Mercurial\hg.exe" Sigcheck v2.72 - File version and signature viewer Copyright (C) 2004-2019 Mark Russinovich Sysinternals - www.sysinternals.com c:\program files (x86)\mercurial\hg.exe: Verified: Unsigned Link date: 17:50 9-7-2019 Publisher: n/a Company: n/a Description: Fast scalable distributed SCM (revision control, version control) system Product: mercurial Prod version: 5.0.2 File version: 5.0.2 MachineType: 32-bit
–jeroen
Leave a Reply