locustio / locust

Write scalable load tests in plain Python 🚗💨
https://locust.cloud
MIT License
25.03k stars 2.99k forks source link

ImportError: cannot import name 'OrderedDict' from 'typing' #2223

Closed jinghaifeng1 closed 2 years ago

jinghaifeng1 commented 2 years ago

Describe the bug

pytnon : 3.7.0 locust: 2.12.1 2.10.1

When I started locust with this configuration, I get an error

Traceback (most recent call last): File "d:\jhf\software\python\python370\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "d:\jhf\software\python\python370\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "D:\jhf\software\python\python370\Scripts\locust.exe__main.py", line 5, in File "d:\jhf\software\python\python370\lib\site-packages\locust\init__.py", line 18, in from .contrib.fasthttp import FastHttpUser File "d:\jhf\software\python\python370\lib\site-packages\locust\contrib\fasthttp.py", line 24, in from locust.env import Environment File "d:\jhf\software\python\python370\lib\site-packages\locust\env.py", line 15, in from .stats import RequestStats, StatsCSV File "d:\jhf\software\python\python370\lib\site-packages\locust\stats.py", line 15, in from typing import ( ImportError: cannot import name 'OrderedDict' from 'typing' (d:\jhf\software\python\python370\lib\typing.py)

Suggestion for repairing

in python370\lib\site-packages\locust\stats.py

del import OrderedDict as OrderedDictType,

replace 326 line "OrderedDictType" to "OrderedDict"

Environment

cyberw commented 2 years ago

I think Python 3.7.0 is broken, please update to at least 3.7.2 (but preferably latest 3.7 release or newer)

jinghaifeng1 commented 2 years ago

I think Python 3.7.0 is broken, please update to at least 3.7.2 (but preferably latest 3.7 release or newer)

OK

Mauricio566 commented 1 month ago

What @cyberw says is true, try version 3.7.9, it worked for me. and thank you very much @cyberw