Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS 10.12.6 -- ERROR: virtualenv is not compatible with this system or executable #631

Closed
dongyuzheng opened this Issue Sep 26, 2017 · 12 comments

Comments

Projects
None yet
3 participants
@dongyuzheng
Copy link

dongyuzheng commented Sep 26, 2017

I'm using python3.6 in venv on macOS 10.12.6:

(venv) Dongyus-MBP:resume-backend gary$ pre-commit
[INFO] Installing environment for https://github.com/asottile/reorder_python_imports.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: Command: ('/Users/gary/backend/venv/bin/python3.6', '-m', 'virtualenv', '/Users/gary/.cache/pre-commit/reporzq6xjqs/py_env-python3.6', '-p', 'python3.6')
Return code: 100
Expected return code: 0
Output:
    Already using interpreter /Users/gary/backend/venv/bin/python3.6
    Using base prefix '/usr/local/bin/../Cellar/python3/3.6.2/bin/../Frameworks/Python.framework/Versions/3.6'
    New python executable in /Users/gary/.cache/pre-commit/reporzq6xjqs/py_env-python3.6/bin/python3.6
    Also creating executable in /Users/gary/.cache/pre-commit/reporzq6xjqs/py_env-python3.6/bin/python
    ERROR: The executable /Users/gary/.cache/pre-commit/reporzq6xjqs/py_env-python3.6/bin/python3.6 is not functioning
    ERROR: It thinks sys.prefix is '/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6' (should be '/Users/gary/.cache/pre-commit/reporzq6xjqs/py_env-python3.6')
    ERROR: virtualenv is not compatible with this system or executable

Errors: (none)

Check the log at /Users/gary/.cache/pre-commit/pre-commit.log

@dongyuzheng dongyuzheng changed the title OSX: ERROR: virtualenv is not compatible with this system or executable macOS 10.12.6 -- ERROR: virtualenv is not compatible with this system or executable Sep 26, 2017

@asottile

This comment has been minimized.

Copy link
Member

asottile commented Sep 26, 2017

Can you show the steps for creating a virtualenv? I have a feeling this is another venv vs virtualenv and/or brew vs system python conflict.

Some useful commands that can help in debugging:

which virtualenv
which python
head -1 $(which virtualenv)
which python3

@asottile asottile added the osx label Sep 26, 2017

@asottile

This comment has been minimized.

Copy link
Member

asottile commented Sep 26, 2017

Also perhaps try:

  • The official installers from python.org
  • making venv using virtualenv instead of -mvenv

as workarounds (fwiw, I've used pre-commit on osx with python3.6 with success)

@dongyuzheng

This comment has been minimized.

Copy link
Author

dongyuzheng commented Sep 26, 2017

Dongyus-MBP:backend gary$ python3.6 -m venv venv
Dongyus-MBP:backend gary$ source venv/bin/activate
(venv) Dongyus-MBP:backend gary$ pip install pre-commit
Collecting pre-commit
  Using cached pre_commit-1.1.2-py2.py3-none-any.whl
Collecting pyyaml (from pre-commit)
  Using cached PyYAML-3.12.tar.gz
Collecting aspy.yaml (from pre-commit)
  Using cached aspy.yaml-0.3.0-py2.py3-none-any.whl
Collecting six (from pre-commit)
  Using cached six-1.11.0-py2.py3-none-any.whl
Collecting identify>=1.0.0 (from pre-commit)
  Using cached identify-1.0.6-py2.py3-none-any.whl
Collecting virtualenv (from pre-commit)
  Using cached virtualenv-15.1.0-py2.py3-none-any.whl
Collecting cached-property (from pre-commit)
  Using cached cached_property-1.3.1-py2.py3-none-any.whl
Collecting nodeenv>=0.11.1 (from pre-commit)
  Using cached nodeenv-1.2.0.tar.gz
Installing collected packages: pyyaml, aspy.yaml, six, identify, virtualenv, cached-property, nodeenv, pre-commit
  Running setup.py install for pyyaml ... done
  Running setup.py install for nodeenv ... done
Successfully installed aspy.yaml-0.3.0 cached-property-1.3.1 identify-1.0.6 nodeenv-1.2.0 pre-commit-1.1.2 pyyaml-3.12 six-1.11.0 virtualenv-15.1.0
(venv) Dongyus-MBP:backend gary$ pre-commit
[INFO] Initializing environment for https://github.com/asottile/reorder_python_imports.
[INFO] Installing environment for https://github.com/asottile/reorder_python_imports.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: Command: ('/Users/gary/backend/venv/bin/python3.6', '-m', 'virtualenv', '/Users/gary/.cache/pre-commit/repolm0_vab7/py_env-python3.6', '-p', 'python3.6')
Return code: 100
Expected return code: 0
Output:
    Already using interpreter /Users/gary/backend/venv/bin/python3.6
    Using base prefix '/usr/local/bin/../Cellar/python3/3.6.2/bin/../Frameworks/Python.framework/Versions/3.6'
    New python executable in /Users/gary/.cache/pre-commit/repolm0_vab7/py_env-python3.6/bin/python3.6
    Also creating executable in /Users/gary/.cache/pre-commit/repolm0_vab7/py_env-python3.6/bin/python
    ERROR: The executable /Users/gary/.cache/pre-commit/repolm0_vab7/py_env-python3.6/bin/python3.6 is not functioning
    ERROR: It thinks sys.prefix is '/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6' (should be '/Users/gary/.cache/pre-commit/repolm0_vab7/py_env-python3.6')
    ERROR: virtualenv is not compatible with this system or executable

Errors: (none)

Check the log at /Users/gary/.cache/pre-commit/pre-commit.log
(venv) Dongyus-MBP:backend gary$ which virtualenv
/Users/gary/backend/venv/bin/virtualenv
(venv) Dongyus-MBP:backend gary$ which python
/Users/gary/backend/venv/bin/python
(venv) Dongyus-MBP:backend gary$ head -1 $(which virtualenv)
#!/Users/gary/backend/venv/bin/python3.6
(venv) Dongyus-MBP:backend gary$ which python3
/Users/gary/backend/venv/bin/python3
@dongyuzheng

This comment has been minimized.

Copy link
Author

dongyuzheng commented Sep 26, 2017

I am able to work around it by changing:

virtualenv to venv: https://github.com/pre-commit/pre-commit/blob/master/pre_commit/languages/python.py#L118

And deleting L121 - L124

@asottile

This comment has been minimized.

Copy link
Member

asottile commented Sep 27, 2017

can you try with python3.6 -m virtualenv venv (to create your initial virtualenv) as a workaround?

Using venv in pre-commit isn't really an option due to python2 users and hooks.

@dongyuzheng

This comment has been minimized.

Copy link
Author

dongyuzheng commented Sep 27, 2017

That works! asottile++

@dongyuzheng

This comment has been minimized.

Copy link
Author

dongyuzheng commented Sep 27, 2017

It would be nice if it can detect if the env was created using venv, and then use that in the env set up.

@asottile

This comment has been minimized.

Copy link
Member

asottile commented Sep 27, 2017

Yeah I agree, I think in the future moving entirely to -mvenv is probably a good idea. The usage of python2 needs to drop much more significantly for that to be considered though.

@ojii

This comment has been minimized.

Copy link
Contributor

ojii commented Apr 25, 2018

I'm having the same issue, but switching to -mvirtualenv is not really an option. Could this be some sort of config option to make pre-commit use -mvenv instead (or auto-use -mvenv if on a recent python)?

@asottile

This comment has been minimized.

Copy link
Member

asottile commented Apr 25, 2018

Curious why -mvirtualenv isn't an option?

@ojii

This comment has been minimized.

Copy link
Contributor

ojii commented Apr 26, 2018

Curious why -mvirtualenv isn't an option?

It's a bootstrapping issue. Using virtualenv, project bootstrapping would look something like this:

  1. Somehow install virtualenv, this may require elevated privileges
  2. python -mvirtualenv env
  3. env/bin/pip install <project-dependencies>

However, we use this instead:

  1. python -mvenv env, no special privileges required
  2. env/bin/pip install <project-dependencies.

There's no benefit in using virtualenv over venv that I can see, but there are drawbacks.

@asottile

This comment has been minimized.

Copy link
Member

asottile commented Apr 26, 2018

Fair, I have a bootstrap script that I tend to use. Virtualenv also is chosen for platform compatibility in this project.

anthrotype added a commit to anthrotype/fonttools that referenced this issue Sep 12, 2018

anthrotype added a commit to anthrotype/fonttools that referenced this issue Sep 12, 2018

travis: 'brew install python' on macOS, use generic py3 tox env
formula is now named just 'python'.
For the homebrew version installed on Travis (which we don't
autoupdate) we *should* get python3.6 with this currently.

It might be the case that python3 is already installed on
Travis macOS image, but need to check.

We call tox with 'TOXENV=py3' so that when Travis updates its homebrew,
we'll get python3.7 automatically.

Finally, use virtualenv instead of venv on mac to fix tox bootstrapping issue

pypa/virtualenv#1051
pre-commit/pre-commit#631
https://travis-ci.org/fonttools/fonttools/jobs/427582922#L214

fixup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.