Electron Build Tools ERROR Error: Failed to run "choco install pywin32 --yes"
- Tan Shuai
- Software Development
- 08 Sep, 2021
When working with Electron Build Tools, you might encounter an error related to the installation of pywin32 via Chocolatey. This can be frustrating, especially when it's a required dependency for your project. Below is a detailed explanation of the issue and potential steps to resolve it.
The Error
When initializing an Electron project using Electron Build Tools, you may see the following error message:
E:\>e init main-testing -i testing --root=e:/src/electron
WARN A fixable error has occurred
--> A required dependency "pywin32" could not be located, it probably has to be installed.
Do you want build-tools to try fix this for you? [y/n]: y
Running "choco install pywin32 --yes"
ERROR Error: Failed to run "choco install pywin32 --yes"
at spawnSyncWithLog (C:\Users\zeeis\.electron_build_tools\src\utils\deps-check.js:11:11)
at fix (C:\Users\zeeis\.electron_build_tools\src\utils\deps-check.js:39:9)
at maybeAutoFix (C:\Users\zeeis\.electron_build_tools\src\utils\maybe-auto-fix.js:13:3)
at whichAndFix (C:\Users\zeeis\.electron_build_tools\src\utils\which.js:10:5)
at checkPlatformDependencies (C:\Users\zeeis\.electron_build_tools\src\utils\deps-check.js:61:7)
at Object.<anonymous> (C:\Users\zeeis\.electron_build_tools\src\e-init.js:165:3)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
This error typically occurs because the pywin32 package installation script cannot find the required files on the remote server. This results in a 404 error, indicating that the file is not available at the specified URL.
Understanding the Error
The key part of the error message is:
ERROR: The remote file either doesn't exist, is unauthorized, or is forbidden for url 'http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/pywin32-219.win-amd64-py3.9.exe/download'. Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (404) Not Found."
This indicates that the download URL for pywin32 is no longer valid, which means Chocolatey cannot retrieve the necessary installation files.
Troubleshooting Steps
Here are a few steps you can take to resolve this issue:
1. Verify Chocolatey Installation
Ensure that Chocolatey is installed correctly and updated to the latest version. You can check your Chocolatey version with:
choco --version
To update Chocolatey, use:
choco upgrade chocolatey
2. Manually Install pywin32
Since the automated installation is failing, try manually installing pywin32. You can download the appropriate version from the official pywin32 GitHub releases page and install it manually.
3. Modify the Installation Script
If you have control over the Electron Build Tools script, you can modify it to point to a valid URL for pywin32 or handle the manual installation process.
4. Use an Alternative Package Manager
If Chocolatey continues to fail, consider using an alternative package manager like pip for Python packages:
pip install pywin32
Example of Manually Installing pywin32
- Download the appropriate pywin32 installer from the official GitHub releases.
- Run the installer and follow the installation instructions.
- Verify the installation by running a simple Python script that imports pywin32:
import win32api
print(win32api.GetVersionEx())
Encountering the "Failed to run choco install pywin32 --yes
" error can be a roadblock in your development process. However, by understanding the root cause and following the steps outlined above, you can overcome this issue and continue with your Electron project setup.