关于Locust遇到的小坑

1.本地装了Python2和Python3,并且各自安装了Locust,运行locust脚本时都会默认使用Pyhon2下的,因为我的项目是用Python3写的,所以需要做以下更改

   在C:Python36Scripts目录下locust.exe 改为 locust2.exe,还需修改 locust-script.py 如下图

  

一开始我是把Pyhon2安装的Locust删掉,结果报failed to create process,其实就是要修改locust-script.py

2.如图,我需要跑的Locust脚本在Loadtests目录下,Tasks目录下的__init__我导入模块时如下

import Actions
import login
__all__ = ['Actions', 'login']

在Pycharm里跑Locust目录下的脚本没问题

结果在cmd运行Locust目录下的脚本报:ModuleNotFoundError: No module named 'Action',然后我改成下面这种就可以了
from Tasks import Actions,login
__all__ = ['Actions', 'login']
原文地址:https://www.cnblogs.com/Akubi/p/9273375.html