Locust: Unable to install on Mac OS X due to errors with greenlet

Created on 27 Apr 2016  ·  13Comments  ·  Source: locustio/locust

Hi,
I'm trying to install Locust on Mac OS X 10.11.3 El Capitan; I've installed libevent with brew and everything was ok.
Then I tried to install locust with pip install locustio, and after lots of warnings the installation completes, but when I try to start locust I get this error:

Traceback (most recent call last):
  File "/usr/local/bin/locust", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2793, in <module>
    working_set.require(__requires__)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 673, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 576, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: greenlet>=0.4.9

And, if I try to re-install locust with Pip, I get this error at the end, relative to greenlet:

Command /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools;__file__='/private/var/folders/vg/s4jrqr550319kf9qx7btjtmr0000gn/T/pip_build_myuserid/greenlet/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/vg/s4jrqr550319kf9qx7btjtmr0000gn/T/pip-VErCi5-record/install-record.txt --single-version-externally-managed failed with error code 1 in /private/var/folders/vg/s4jrqr550319kf9qx7btjtmr0000gn/T/pip_build_myuserid/greenlet

Am I missing something?

Most helpful comment

Try pip install --user locustio instead of using sudo.

All 13 comments

I get errors relating to greenlet as well:

    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/w4/vs2_z7wn703c2zxlcxf9z6hc0000gn/T/pip-build-wyDQVn/greenlet/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/w4/vs2_z7wn703c2zxlcxf9z6hc0000gn/T/pip-hRauvk-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'greenlet' extension
    creating build
    creating build/temp.macosx-10.11-intel-2.7
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c greenlet.c -o build/temp.macosx-10.11-intel-2.7/greenlet.o
    creating build/lib.macosx-10.11-intel-2.7
    cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.11-intel-2.7/greenlet.o -o build/lib.macosx-10.11-intel-2.7/greenlet.so
    running install_lib
    copying build/lib.macosx-10.11-intel-2.7/greenlet.so -> /Library/Python/2.7/site-packages
    error: could not delete '/Library/Python/2.7/site-packages/greenlet.so': Permission denied

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/w4/vs2_z7wn703c2zxlcxf9z6hc0000gn/T/pip-build-wyDQVn/greenlet/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/w4/vs2_z7wn703c2zxlcxf9z6hc0000gn/T/pip-hRauvk-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/w4/vs2_z7wn703c2zxlcxf9z6hc0000gn/T/pip-build-wyDQVn/greenlet/

I'm able to pip install locustio into a clean virtualenv, so it doesn't seem to be "globally" broken.

@z5h: Did you try to install Locust into a virtualenv? If not, could you try it? (I'm guessing here, but the permission denied message seems to indicate that it's trying to install greenlet as a system package, which you might need root permissions to do)

@heyman
Someone on stackoverflow suggested against using the Python(s) included in OS X.
I did a
brew install python
rehash
verified python and pip were the newly installed ones, then
pip install locustio.

For me that's good enough and I've made some satisfactory progress getting started with locust.
Why it didn't work on the default OS X Python is beyond my understanding or concern.

@z5h
The error you posted is "Permission denied". This is happening with the default Python because you are trying to use pip to install as a system package. Your personal user account does not have privileges to install packages into your default Python installation. You would either need to switch to a root user, or better yet, call pip using "sudo".

$ sudo pip install locust will install it globally as a system package. While this works, it is not recommended to mess with system packages. Better to use a virtualenv.

@cgoldberg I tried the command with sudo and had another issue. I tried creating a .pydistutils.cfg and installing with something else. (Forgive my ignorance, I'm a long time dev but don't use Python).

In any case. Nothing else worked. Homebrew Python worked.

Sorry for late reply. Anyway; I solved by re-installing python with brew, then remove locust and reinstall locust via pip.
A better solution, in the end, is to use one of the Python 3 forks of Locust, and build them manually with python3.

Regarding the issue, might it be useful to update the REAME for Mac OS X users?

I got the same problem, any good solution so far? I don't want to reinstall python, this solutions seems to be very weird.

The weirdest thing is that I can install greenlet by itself, but when I try to install locust, pip decides to reinstall greenlets for some reason and ends up shooting in it's leg:

Installing collected packages: greenlet, gevent, pyzmq, locustio
  Found existing installation: greenlet 0.4.9
    Uninstalling greenlet-0.4.9:
      Successfully uninstalled greenlet-0.4.9
  Running setup.py install for greenlet ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-zrl4X5/greenlet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-VfmRbH-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'greenlet' extension
    creating build
    creating build/temp.macosx-10.12-intel-2.7
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c greenlet.c -o build/temp.macosx-10.12-intel-2.7/greenlet.o
    creating build/lib.macosx-10.12-intel-2.7
    cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.12-intel-2.7/greenlet.o -o build/lib.macosx-10.12-intel-2.7/greenlet.so
    running install_lib
    copying build/lib.macosx-10.12-intel-2.7/greenlet.so -> /Library/Python/2.7/site-packages
    running install_headers
    creating /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/greenlet
    error: could not create '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/greenlet': Operation not permitted

    ----------------------------------------
  Rolling back uninstall of greenlet
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-zrl4X5/greenlet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-VfmRbH-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-zrl4X5/greenlet/

@DataGreed
are you trying to install the locust package into your system Python packages (/Library/Python/2.7/site-packages) as a regular user? That won't work since your user probably doesn't have access.

You have a few choices for installing locust:
1) install into system python packages with elevated access ($ sudo pip install locustio)
2) install into an activated virtualenv
3) install another Python version somewhere else and install into that

@cgoldberg for sure, I was trying to do it with sudo, but that does not help.

I ended up installing it in virtual environment.

Try pip install --user locustio instead of using sudo.

@cooperka , i get this error, can u please explain me what it is and how to solve it?
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/41/39h1bf895ssgkt134m67b9fr0000gn/T/pip-install-SqzOUR/pyTelegramBotAPI/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/41/39h1bf895ssgkt134m67b9fr0000gn/T/pip-record-1ahjQs/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/41/39h1bf895ssgkt134m67b9fr0000gn/T/pip-install-SqzOUR/pyTelegramBotAPI/

I was having install problems too but I fixed mine by installing command line tools:
xcode-select --install

Was this page helpful?
0 / 5 - 0 ratings