ImportError: DLL load failed while importing win32console【pywin32】

昨天晚上电脑提示更新,没理他,结果早上要看系统自动更新重启了已经。重新启动faceswap的时候就报了下面的错误:

F:\faceswap\fs>"C:\Users\obaby\Anaconda3\scripts\activate.bat" && conda activate "fs" && python "F:\faceswap\faceswap/faceswap.py" gui
Setting Faceswap backend to NVIDIA
12/16/2021 07:22:00 INFO Log level set to: INFO
12/16/2021 07:22:04 ERROR Got Exception on main handler:
Traceback (most recent call last):
File "F:\faceswap\faceswap\lib\cli\launcher.py", line 180, in execute_script
script = self._import_script()
File "F:\faceswap\faceswap\lib\cli\launcher.py", line 46, in _import_script
module = import_module(mod)
File "E:\anaconda_dirs\venvs\fs\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 843, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "F:\faceswap\faceswap\scripts\gui.py", line 9, in <module>
from lib.gui import (TaskBar, CliOptions, CommandNotebook, ConsoleOut, DisplayNotebook,
File "F:\faceswap\faceswap\lib\gui\__init__.py", line 12, in <module>
from lib.gui.wrapper import ProcessWrapper
File "F:\faceswap\faceswap\lib\gui\wrapper.py", line 18, in <module>
import win32console # pylint: disable=import-error
ImportError: DLL load failed while importing win32console: 找不到指定的模块。
12/16/2021 07:22:04 CRITICAL An unexpected crash has occurred. Crash report written to 'F:\faceswap\faceswap\crash_report.2021.12.16.072202080315.log'. You MUST provide this file if seeking assistance. Please verify you are running the latest version of faceswap before reporting

尝试通过pip安装pywin32发现已经存在了:

(E:\anaconda_dirs\venvs\fs) C:\Users\obaby>pip install pypiwin32
Collecting pypiwin32
Downloading pypiwin32-223-py3-none-any.whl (1.7 kB)
Requirement already satisfied: pywin32>=223 in e:\anaconda_dirs\venvs\fs\lib\site-packages (from pypiwin32) (302)
Installing collected packages: pypiwin32
Successfully installed pypiwin32-223

(E:\anaconda_dirs\venvs\fs) C:\Users\obaby>pip install pywin32
Requirement already satisfied: pywin32 in e:\anaconda_dirs\venvs\fs\lib\site-packages (302)

运行依旧报错,后来搜索了一下发现了这个帖子https://blog.csdn.net/ljr_123/article/details/104693372,

参考里面的步骤:

1.从https://pypi.org/project/pywin32/#description下载对应的安装包。

2.解压之后通过下面的命令安装:

python Scripts/pywin32_postinstall.py -install

安装日志:

(E:\anaconda_dirs\venvs\fs) C:\Users\obaby>python C:\Users\obaby\Downloads\pywin32-302.win-amd64-py3.8\SCRIPTS\pywin32_postinstall.py -install
Parsed arguments are: Namespace(destination='E:\\anaconda_dirs\\venvs\\fs\\Lib\\site-packages', install=True, quiet=False, remove=False, silent=False, wait=None)
Copied pythoncom38.dll to E:\anaconda_dirs\venvs\fs\pythoncom38.dll
Copied pywintypes38.dll to E:\anaconda_dirs\venvs\fs\pywintypes38.dll
You do not have the permissions to install COM objects.
The sample COM objects were not registered.
-> Software\Python\PythonCore\3.8\Help[None]=None
-> Software\Python\PythonCore\3.8\Help\Pythonwin Reference[None]='E:\\anaconda_dirs\\venvs\\fs\\Lib\\site-packages\\PyWin32.chm'
Registered help file
Pythonwin has been registered in context menu
Creating directory E:\anaconda_dirs\venvs\fs\Lib\site-packages\win32com\gen_py
Shortcut for Pythonwin created
Shortcut to documentation created
The pywin32 extensions were successfully installed.

对于这个错误的解决,其实官网上已经有提示了:

If you encounter any problems when upgrading (eg, “module not found” errors or similar), you should execute:
python Scripts/pywin32_postinstall.py -install

安装之后会提示com组件没有安装:The sample COM objects were not registered.

此时运行需要com组件支持的代码就会提示下面的错误:

(E:\anaconda_dirs\venvs\fs) C:\Users\obaby>anaconda upload C:\Users\obaby\Documents\fs.yaml
Traceback (most recent call last):
File "C:\Users\obaby\Anaconda3\Scripts\anaconda-script.py", line 5, in <module>
from binstar_client.scripts.cli import main
File "C:\Users\obaby\Anaconda3\lib\site-packages\binstar_client\__init__.py", line 17, in <module>
from .utils import compute_hash, jencode, pv
File "C:\Users\obaby\Anaconda3\lib\site-packages\binstar_client\utils\__init__.py", line 17, in <module>
from .config import (get_server_api, dirs, load_token, store_token,
File "C:\Users\obaby\Anaconda3\lib\site-packages\binstar_client\utils\config.py", line 54, in <module>
USER_LOGDIR = dirs.user_log_dir
File "C:\Users\obaby\Anaconda3\lib\site-packages\binstar_client\utils\appdirs.py", line 257, in user_log_dir
return user_log_dir(self.appname, self.appauthor,
File "C:\Users\obaby\Anaconda3\lib\site-packages\binstar_client\utils\appdirs.py", line 205, in user_log_dir
path = user_data_dir(appname, appauthor, version); version = False
File "C:\Users\obaby\Anaconda3\lib\site-packages\binstar_client\utils\appdirs.py", line 67, in user_data_dir
path = os.path.join(_get_win_folder(const), appauthor, appname)
File "C:\Users\obaby\Anaconda3\lib\site-packages\binstar_client\utils\appdirs.py", line 284, in _get_win_folder_with_pywin32
from win32com.shell import shellcon, shell
ImportError: DLL load failed while importing shell: 找不到指定的程序。

尝试以管理员权限权限安装没有成功提示找不到pythonw_d.exe,早上时间太匆忙了,还没搞明白怎么解决,后续再去处理。不过到现在faceswap可以运行了。

 

 

☆版权☆

* 网站名称:obaby@mars
* 网址:https://oba.by/
* 个性:https://oba.by/
* 本文标题: 《ImportError: DLL load failed while importing win32console【pywin32】》
* 本文链接:https://lang.bi/2021/12/9601
* 短链接:https://oba.by/?p=9601
* 转载文章请标明文章来源,原文标题以及原文链接。请遵从 《署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5 CN) 》许可协议。


You may also like

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注