5

I am trying the locust quick start in my mac and I am getting this error for any import I try. I have python 2.7 and python 3.7 installed in my machine but i use only python 3.7

➜  ~ python -V
Python 2.7.16
➜  ~ python3 -V
Python 3.7.5

my locust version is: 1.4.3

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/xxxxx/xxxxx/xxxxx/xxxxx/locust.py", line 3, in <module>
    from locust import HttpUser, task, between
ImportError: cannot import name 'HttpUser' from 'locust' (/Users/xxxxx/xxxxx/xxxxx/xxxxx/locust.py)```
Eli m
  • 83
  • 1
  • 7
  • If you type into the terminal `python3 -m pip list` does the module show up there? Are you using `python3 -m pip install` to install modules? – Rolv Apneseth Feb 23 '21 at 12:52
  • yes, the module shows up in the list yes, I used pip3 install locust, not python3 -m pip install as i always do – Eli m Feb 24 '21 at 13:12

1 Answers1

10

It seems that you have named the locust file locust.py instead of locustfile.py as quick-start suggest. I think that perhaps that will be causing you to fail the imports from the same file.

Can't tell properly without a way to test it or more details related to how you are running locust.

Try changing the filename of the locust test scenarios

aekis.dev
  • 2,626
  • 1
  • 12
  • 19