ImportError: The HttpLocust class has been renamed to HttpUser in version 1.0

ImportError: The HttpLocust class has been renamed to HttpUser in version 1.0

我是 Locust 的新手,几天前才开始修修补补。 为了快速开始,我正在按照下面的其他示例进行操作, 文件:locustfile.py

import random
from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):
    def on_start(self):
        """ on_start is called when a Locust start before 
            any task is scheduled
        """
        self.login()
    def login(self):
        self.client.post("/login",
                         {"username":"ellen_key",
                          "password":"education"})
    @task(2)
    def index(self):
        self.client.get("/")
    @task(1)
    def profile(self):
        self.client.get("/profile")
class WebsiteUser(HttpLocust):
    task_set = UserBehavior
    min_wait = 5000
    max_wait = 9000

当我从当前目录 运行 locust 时,出现以下异常,

Traceback (most recent call last):
  File "/usr/local/bin/locust", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/locust/main.py", line 113, in main
    docstring, user_classes = load_locustfile(locustfile)
  File "/usr/local/lib/python3.6/dist-packages/locust/main.py", line 77, in load_locustfile
    imported = __import_locustfile__(locustfile, path)
  File "/usr/local/lib/python3.6/dist-packages/locust/main.py", line 53, in __import_locustfile__
    return  source.load_module()
  File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 823, in load_module
  File "<frozen importlib._bootstrap_external>", line 682, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 684, in _load
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/koushic/kk-ldl/locust/locustfile.py", line 19, in <module>
    class WebsiteUser(HttpLocust):
  File "/usr/local/lib/python3.6/dist-packages/locust/util/deprecation.py", line 23, in __new__
    raise ImportError(deprecation_message)
ImportError: The HttpLocust class has been renamed to HttpUser in version 1.0. For more info see: https://docs.locust.io/en/latest/changelog.html#changelog-1-0

谁能帮我理解这里的问题。

Python 3.6.9
pip 20.1.1

只需检查错误信息的最后一行:

ImportError: The HttpLocust class has been renamed to HttpUser in version 1.0. For more info see: https://docs.locust.io/en/latest/changelog.html#changelog-1-0

如果幸运的话,您需要做的就是更改这两行:

from locust import HttpUser, TaskSet, task

class 网站用户(Http用户):