locustio / locust

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

ModuleNotFoundError in Python 3.6 OSX 10.12 #627

Closed chhantyal closed 7 years ago

chhantyal commented 7 years ago

I use Python 3.6 installed via Homebrew. There seems to be import issue, I am exactly not sure why as I see tests for Python 3.6 seems to be passing.

$ locust locustfile.py
Traceback (most recent call last):
  File "/usr/local/bin/locust", line 7, in <module>
    from locust.main import main
  File "/usr/local/lib/python3.6/site-packages/locust/__init__.py", line 1, in <module>
    from core import HttpLocust, Locust, TaskSet, task
ModuleNotFoundError: No module named 'core'

Version: locustio ==0.7.5

$ which locust
/usr/local/bin/locust
cgoldberg commented 7 years ago

@chhantyal

I use Python 3.6

The issue you are having is because version 0.7.5 is only compatible with Python 2.7. To get Python 3 support you must install Locust 0.8. As of today (7/21/2017) it has not been officially released... so you have 2 options:

  1. install the 0.8a2 pre-release from PyPI: pip install locustio==0.8a2
  2. install the latest master branch from the git repository: pip install git+https://github.com/locustio/locust.git

I see tests for Python 3.6 seems to be passing

Python 3.6 tests do pass in current master branch, but you'll notice the v0.7.5 branch does not test against against Python 3.x: https://travis-ci.org/locustio/locust/builds/135922735

hth

chhantyal commented 7 years ago

Thanks for detail information. Much appreciated. I totally missed to check versions released.

On the side note, last release seems to be from a year ago. May be time to release 3.6 support? Other users seem to have same confusion, eg #630

MarcSteven commented 4 years ago

The issue is still existing I used the python 3.8.2

gkandale commented 4 years ago

I'm getting the issue too... (venv) gkandale@GKAND msx_platform_src % python3 --version Python 3.8.2 (venv) gkandale@GKAND msx_platform_src % locust --version locust 0.14.6

(venv) gkandale@GKANDALE-M-9325 msx_platform_src % locust -f msx_login.py
[2020-05-08 22:11:08,190] GKANDALE-M-9325/ERROR/stderr: Traceback (most recent call last):
[2020-05-08 22:11:08,190] GKANDALE-M-9325/ERROR/stderr: File "/Library/Frameworks/Python.framework/Versions/3.8/bin/locust", line 10, in <module>
[2020-05-08 22:11:08,190] GKANDALE-M-9325/ERROR/stderr: 
[2020-05-08 22:11:08,190] GKANDALE-M-9325/ERROR/stderr: sys.exit(main())
[2020-05-08 22:11:08,190] GKANDALE-M-9325/ERROR/stderr: 
[2020-05-08 22:11:08,190] GKANDALE-M-9325/ERROR/stderr: File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/locust/main.py", line 420, in main
[2020-05-08 22:11:08,191] GKANDALE-M-9325/ERROR/stderr: 
[2020-05-08 22:11:08,192] GKANDALE-M-9325/ERROR/stderr: docstring, locusts = load_locustfile(locustfile)
[2020-05-08 22:11:08,192] GKANDALE-M-9325/ERROR/stderr: 
[2020-05-08 22:11:08,192] GKANDALE-M-9325/ERROR/stderr: File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/locust/main.py", line 389, in load_locustfile
[2020-05-08 22:11:08,192] GKANDALE-M-9325/ERROR/stderr: 
[2020-05-08 22:11:08,192] GKANDALE-M-9325/ERROR/stderr: imported = __import_locustfile__(locustfile, path)
[2020-05-08 22:11:08,192] GKANDALE-M-9325/ERROR/stderr: 
[2020-05-08 22:11:08,192] GKANDALE-M-9325/ERROR/stderr: File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/locust/main.py", line 365, in __import_locustfile__
[2020-05-08 22:11:08,192] GKANDALE-M-9325/ERROR/stderr: 
[2020-05-08 22:11:08,192] GKANDALE-M-9325/ERROR/stderr: return  source.load_module()
[2020-05-08 22:11:08,192] GKANDALE-M-9325/ERROR/stderr: 
[2020-05-08 22:11:08,192] GKANDALE-M-9325/ERROR/stderr: File "<frozen importlib._bootstrap_external>", line 462, in _check_name_wrapper
[2020-05-08 22:11:08,192] GKANDALE-M-9325/ERROR/stderr: File "<frozen importlib._bootstrap_external>", line 962, in load_module
[2020-05-08 22:11:08,193] GKANDALE-M-9325/ERROR/stderr: File "<frozen importlib._bootstrap_external>", line 787, in load_module
[2020-05-08 22:11:08,193] GKANDALE-M-9325/ERROR/stderr: File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
[2020-05-08 22:11:08,193] GKANDALE-M-9325/ERROR/stderr: File "<frozen importlib._bootstrap>", line 702, in _load
[2020-05-08 22:11:08,193] GKANDALE-M-9325/ERROR/stderr: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
[2020-05-08 22:11:08,193] GKANDALE-M-9325/ERROR/stderr: File "<frozen importlib._bootstrap_external>", line 783, in exec_module
[2020-05-08 22:11:08,193] GKANDALE-M-9325/ERROR/stderr: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[2020-05-08 22:11:08,193] GKANDALE-M-9325/ERROR/stderr: File "/Users/gkandale/LocustProjects/MSXProjects/msx_platform/venv/msx_platform_src/msx_login.py", line 2, in <module>
[2020-05-08 22:11:08,193] GKANDALE-M-9325/ERROR/stderr: 
[2020-05-08 22:11:08,193] GKANDALE-M-9325/ERROR/stderr: from data import user_credentials
[2020-05-08 22:11:08,193] GKANDALE-M-9325/ERROR/stderr: 
[2020-05-08 22:11:08,193] GKANDALE-M-9325/ERROR/stderr: ModuleNotFoundError
[2020-05-08 22:11:08,194] GKANDALE-M-9325/ERROR/stderr: :
[2020-05-08 22:11:08,194] GKANDALE-M-9325/ERROR/stderr: No module named 'data'
[2020-05-08 22:11:08,194] GKANDALE-M-9325/ERROR/stderr: 
heyman commented 4 years ago

@gkandale

The stacktrace seems to indicate that the error originates from your test scripts, and not from Locust.