python中的locust库,启动报错:DLL load failed while importing win32api: 找不到指定的模块。

在运行启动locus命令后:报错

Traceback (most recent call last):
  File "D:\python\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\python\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\python\Scripts\locust.exe\__main__.py", line 4, in <module>
  File "D:\python\lib\site-packages\locust\main.py", line 28, in <module>
    from .input_events import input_listener
  File "D:\python\lib\site-packages\locust\input_events.py", line 9, in <module>
    from win32api import STD_INPUT_HANDLE
ImportError: DLL load failed while importing win32api: 找不到指定的模块。

查找网上资料,花了一番周折终于找到了,当然还是没搞明白原理是什么(手动狗头)

1. 找到python安装目录,找到“pywin32_postinstall.py”这个文件

2. cmd当前目录,执行:

python pywin32_postinstall.py -install

3. 运行结果如下:

Parsed arguments are: Namespace(destination='D:\\python\\Lib\\site-packages', install=True, quiet=False, remove=False, silent=False, wait=None)
pywin32_postinstall.py:164: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
Copied pythoncom38.dll to D:\python\pythoncom38.dll
Copied pywintypes38.dll to D:\python\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]='D:\\python\\Lib\\site-packages\\PyWin32.chm'
Pythonwin has been registered in context menu
('Creating directory', 'D:\\python\\Lib\\site-packages\\win32com\\gen_py')
Shortcut for Pythonwin created
Shortcut to documentation created
The pywin32 extensions were successfully installed.

4.再cmd窗口,执行locus命令,这下不报错了:

[2023-09-02 14:22:26,882] DESKTOP-ABLQKR5/INFO/locust.main: Starting web interface at http://0.0.0.0:8089 (accepting connections from all network interfaces)
[2023-09-02 14:22:26,892] DESKTOP-ABLQKR5/INFO/locust.main: Starting Locust 2.16.1

5. 访问该地址:http://0.0.0.0:8089。可惜打不开:

6. 修改为:http://127.0.0.1:8089,依旧打不开

7. 经网上资料,修改argument_parser.py文件中的web_ui_group.add_argument这个方法,把default修改为:127.0.0.1(默认为空),

8. cmd命令运行:locust -f locustfile.py --web-host="127.0.0.1"

8.重新访问。成功!

相关参考链接:

https://www.cnblogs.com/Swalllow/p/11711750.html

https://blog.csdn.net/weixin_41494909/article/details/124533095

感谢!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ImportError: DLL load failed是一种Python误,它通常发生在导入某个模块时出现问题。这个误信息表明Python无法加载所需的动态链接(DLL)模块。根据引用和引用的信息,这个误可能与导入matplotlib模块相关。一种可能的解决方法是检查是否已正确安装了matplotlib模块。你可以通过引用提供的URL链接来下载和安装适合你操作系统和Python版本的matplotlib模块。另外,你还可以尝试更新或重新安装matplotlib模块以解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ImportError: DLL load failed: 不到指定模块。](https://download.csdn.net/download/weixin_38637884/13742003)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [ImportError:DLL load failed不到指定模块。终极无敌解决方法!(点赞支持一下新手)](https://blog.csdn.net/fish_turtle/article/details/118638751)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值