Virtualenv error on osx build




I’m using the new OSX stack and my project fails with some crude error about virtualenv (used in the python world). Here is the error:

((if (directory? “/Users/distiller/virtualenvs/venv-system”) (echo “Using cached venv”) (do (“virtualenv” “/Users/distiller/virtualenvs/venv-system” || exit 1) (source “/Users/distiller/virtualenvs/venv-system/bin/activate” || exit 2) (pip install nose || exit 3))) “rm -rf venv; ln -s /Users/distiller/virtualenvs/venv-system venv” (echo “source /Users/distiller/virtualenvs/venv-system/bin/activate” >> “~/.circlerc”)) returned exit code 1

bash: line 2: virtualenv: command not found Action failed: virtualenv[/quote]

This occurs in the “machine” section right after “Select Xcode Version” and “Restore cache”. I have no idea what to do about this, as “Rebuild without cache” also has no effect on this.


After a whole bunch of debugging commits I found a solution:

        - pip install --user --ignore-installed --upgrade --verbose virtualenv
        - ln -s ~/Library/Python/2.7/bin/virtualenv /usr/local/bin/virtualenv

But I think this should be fixed in the image …


Just out of curiosity what are you using python for in your build?


Python is not used in the project directly but as glue-code to manage the rather complex build command


I see, that makes a lot of sense.

@alexey do you think this is something we could address in the build image?


Thanks for the details, @michaelcontento. We’ll see if we can pre-install virtualenv in OS X build containers to make sure this doesn’t happen.


FYI, for me just

    - sudo -H pip install --upgrade virtualenv

did the trick.


Thanks @sschuberth and @michaelcontento - this has highlighted that we were missing some tests for our macOS image. We will get virtualenv installed properly, and add proper regression tests for our image builder so that we don’t make this mistake again.


The workarounds stopped working due to

My solution is to upgrade pip beforehand:

    # virtualenv is automatically used by CircleCI,
    # but it's not available in the macOS image.
    - curl | sudo python -
    - sudo -H pip install --upgrade virtualenv


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.