Locust: Successfully installed but locust command not found on macOS Sierra 10.12

Created on 30 Mar 2017  ·  15Comments  ·  Source: locustio/locust

Hi,

I use python version 2.7.10 on OSX 10.12.

I first installed the locustio using the command "pip install locustio" then I got an error of " error: could not create '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/greenlet': Operation not permitted"

Then I tried to use command "pip install --user locustio", it says lucustio installed successfully!

"Collecting locustio
Using cached locustio-0.7.5.tar.gz
Collecting gevent==1.1.1 (from locustio)
Using cached gevent-1.1.1-cp27-cp27m-macosx_10_6_intel.whl
Collecting flask>=0.10.1 (from locustio)
Using cached Flask-0.12-py2.py3-none-any.whl
Collecting requests>=2.9.1 (from locustio)
Using cached requests-2.13.0-py2.py3-none-any.whl
Collecting msgpack-python>=0.4.2 (from locustio)
Using cached msgpack-python-0.4.8.tar.gz
Collecting greenlet>=0.4.9 (from gevent==1.1.1->locustio)
Using cached greenlet-0.4.12.tar.gz
Collecting itsdangerous>=0.21 (from flask>=0.10.1->locustio)
Using cached itsdangerous-0.24.tar.gz
Collecting Werkzeug>=0.7 (from flask>=0.10.1->locustio)
Using cached Werkzeug-0.12.1-py2.py3-none-any.whl
Collecting Jinja2>=2.4 (from flask>=0.10.1->locustio)
Using cached Jinja2-2.9.5-py2.py3-none-any.whl
Collecting click>=2.0 (from flask>=0.10.1->locustio)
Using cached click-6.7-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->flask>=0.10.1->locustio)
Using cached MarkupSafe-1.0.tar.gz
Installing collected packages: greenlet, gevent, itsdangerous, Werkzeug, MarkupSafe, Jinja2, click, flask, requests, msgpack-python, locustio
Running setup.py install for greenlet ... done
Running setup.py install for itsdangerous ... done
Running setup.py install for MarkupSafe ... done
Running setup.py install for msgpack-python ... done
Running setup.py install for locustio ... done
Successfully installed Jinja2-2.9.5 MarkupSafe-1.0 Werkzeug-0.12.1 click-6.7 flask-0.12 gevent-1.1.1 greenlet-0.4.12 itsdangerous-0.24 locustio-0.7.5 msgpack-python-0.4.8 requests-2.13.0
"

However, when I type locust I get an error of "command not found"?

Please does someone know what is going on?

Thank you!

Most helpful comment

I'd recommend installing Locust in a virtualenv. To do this, you need to:

  • Create a virtualenv: virtualenv venv (venv is the name, it can be called anything)
  • Activate the virtualenv: source venv/bin/activate (now if you run which python it should point within the venv dir)
  • Install locust: pip install locustio

See the virtualenv docs for more info.

All 15 comments

pip --version
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)

virtualenv --version
15.1.0

Hi!

Have you created, and activated, a virtualenv when you're doing this?

I think one could get that error if Locust were installed system globally while the system global python bin path wasn't on the $PATH environment variable.

I first tried to install the Locust on virtualenv and it failed due to the same error "error: could not create '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/greenlet': Operation not permitted". Then I used command "pip install --user locustio" to install.

After run: $which -a python
I got: /usr/bin/python

echo $PATH
/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Should I add "/usr/bin/python" to my path?

Thank you very much!

I'd recommend installing Locust in a virtualenv. To do this, you need to:

  • Create a virtualenv: virtualenv venv (venv is the name, it can be called anything)
  • Activate the virtualenv: source venv/bin/activate (now if you run which python it should point within the venv dir)
  • Install locust: pip install locustio

See the virtualenv docs for more info.

just for clarity.... the "Operation not permitted" error means you are trying to install locust into your system site-packages without sudo access. You could sudo pip install locustio to get around it and make it available system wide... but the suggestion to use a virtualenv is a better solution.

@heyman I have tried your way, it works! Thanks very much~~

@cgoldberg I have tried "sudo pip install locustio", not work for me. Then I tried "sudo -H pip install locustio", not work either. I don't know why......

try this pip install --user locustio

ln ~/Library/Python/2.7/bin/locust /usr/local/bin

I had the same problem and I found /Users//Library/Python was owned by root.
Changing the owner solved my problem:

chown -R :staff /Users//Library/Python

combined what @AnastasyaHutasoi and @RogerGan said and it worked. I think it's because the default install of python on a mac needs to be replaced. Guess this could have been done by adding it to your PATH in bashrc or zshrc or wahteverrc

just use a virtualenv

I use pip install locustio --user to install locust and can't find the command in zsh on my Mac too.
It is a environment PATH problem, I add a command in .zshrc file as blew to fix the problme.

export PATH=$PATH:/Users/rain/Library/Python/2.7/bin

I have the same problem, except I also have the same problem for virtualenv. Should I use virtualenv for virtualenv? ;)

reboot your machine may it will fix in my case it worked.I have python 3.6.9 in my machine

Was this page helpful?
0 / 5 - 0 ratings