Background
Using wxauto to develop wechat robot, there was an error when running the program in Pycharm
Error prompt
Traceback (most recent call last):
File "D:\Project\wechatBot\test.py", line 2, in <module>
from wxauto import WeChat
File "C:\Users\pokeu\anaconda3\envs\wechatbot\lib\site-packages\wxauto\__init__.py", line 2, in <module>
from .wxauto import WxParam, WxUtils, WeChat, COPYDICT
File "C:\Users\pokeu\anaconda3\envs\wechatbot\lib\site-packages\wxauto\wxauto.py", line 10, in <module>
import win32gui, win32con
ImportError: DLL load failed while importing win32gui: Can't find the specified program.
Solution:
Check if the win32gui.pyd file exists in the C:\Users\username\anaconda3\envs\wechatbot\Lib\site-packages\win32 directory
If not, run pip install pywin32 to install it.
Add C:\Users\username\anaconda3\envs\wechatbot\Lib\site-packages\pywin32_system32 to the system environment variable.
Notes.
a. User name Replace with your own user name.
b. The first half of C:\Users\username\anaconda3 is the installation path of anaconda, replace it with your own.
c. \envs\wechatbot is the path of the new environment I created (wechatbot), replace it with your own environment, or ignore it if you didn’t create it, and just find \Lib\site-packages\win32.
In the original import … import the following library before the original import …: import pywintypes, e.g.
import pywintypes
#import pythoncom # Uncomment this if some other DLL load will fail
from wxauto import WeChat
import time, random
Now run the program again, and there should be no error.
Read More:
- Import win32API; importerror: DLL load failed: the specified program was not found
- import statsmodels.api as sm Error: ImportError: DLL load failed while importing _arpack: The specified program could not be found.
- How to Solve Python Importerror: DLL load failed: unable to find the specified program using tensorflow
- ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.
- [Solved] D2lzh_Pytorch Import error: importerror: DLL load failed while importing
- Importerror: DLL load failed: unable to find the specified module in Python
- [Solved] Numpy Load Error: DLL load failed while importing _multiarray_umath: Could not be found Module
- [Solved] Converting IU to py using pyuic5 – O reports an error importerror: DLL load failed while importing qtcore: the specified module cannot be found.
- [Solved] DLL load failed while importing _sqlite3: the specified module could not be found.
- DLL load failed while importing rdBase [How to Solve]
- [Solved] Sklearn Call Error: DLL load failed while importing _arpack
- Jupyter notebook Failed to Switch to the Virual Environment: DLL load failed python.exe could not find the entry
- Pycharm error: original error was: DLL load failed while importing _multiarray _Umath: the specified module could not be found
- [Solved] librosa Install Error: ImportError: DLL load failed: Could Not Found
- [Solved] Original error was: DLL load failed while importing _multiarray_umath
- Pyinstaller Error: [ImportError]: DLL load failed while importing _socket: Parameter error
- VScode import numpy Error: DLL load failed [How to Solve]
- Ctypes DLL Error: FileNotFoundError: Could not find module ‘***_dll.dll‘ (or one of its dependencies).
- TensorFlow Install Error: Could not load dynamic library ‘*****.dll‘; dlerror: ********.dll not found
- [Solved] torchvision Error: UserWarning: Failed to load image Python extension: Could not find module