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:
- How to Solve Python Importerror: DLL load failed: unable to find the specified program using tensorflow
- [Mac Pro M1] Python3.9 import cv2 Error: Reason: image not found
- Import win32API; importerror: DLL load failed: the specified program was not found
- [Solved] Pdfplumber Read PDF Sheet Error: AttributeError: function/symbol ‘ARC4_stream_init‘ not found in library
- [Solved] Python matplotlib Error: RuntimeError: In set_size: Could not set the fontsize…
- Python PIP TypeError: expected str, bytes or os.PathLike object, not int
- [Solved] Paramiko error: AttributeError: ‘NoneType’ object has no attribute ‘time’
- [Solved] bert_as_service startup error: Tensorflow 2.1.0 is not tested!
- Importerror: DLL load failed: unable to find the specified module in Python
- [Solved] mmdetection benchmark.py Error: RuntimeError: Distributed package doesn‘t have NCCL built in
- Install PyTorch in Anaconda environment
- An error is reported in the requirements code of the generated project
- Python Error: OSError: cannot open resource [How to Solve]
- AttributeError: can‘t set attribute [How to Solve]
- Pytorch ValueError: Expected more than 1 value per channel when training, got input size [1, 768
- Python pyqt5 ui Generate .py File Error [How to Solve]
- import statsmodels.api as sm Error: ImportError: DLL load failed while importing _arpack: The specified program could not be found.
- [How to Solve] ImportError: No module named typing
- [Solved] OpenCV Import Error: ImportError: numpy.core.multiarray failed to import
- OSError libespeak.so.1 error: no such file or directory [How to Solve]