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

Bazel doesn't recognize that /usr/bin/python is Python 3, not 2. #6744

Closed
philwo opened this issue Nov 22, 2018 · 5 comments
Closed

Bazel doesn't recognize that /usr/bin/python is Python 3, not 2. #6744

philwo opened this issue Nov 22, 2018 · 5 comments
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Python Native rules for Python type: bug

Comments

@philwo
Copy link
Member

philwo commented Nov 22, 2018

Description of the problem / feature request:

On systems where "python" on the PATH is Python 3 (e.g. Arch Linux has /usr/bin/python = Python3, also some macOS Homebrew installations seem to have /usr/local/bin/python as Python3), Bazel doesn't realize that and believes it's using Python 2.

Thus py_binary's that use PY2 (which is still the default for Bazel, so that would be almost all binaries) and are not compatible with Python 3 will mysteriously fail to run.

Some examples of where this caused confusion:

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Bazel should detect the correct Python 2.x and 3.x versions from the PATH, by inspecting the version output of "python", "python2" and "python3" and then choosing appropriate binaries.

What operating system are you running Bazel on?

Arch Linux

@philwo philwo added type: bug P2 We'll consider working on this in future. (Assignee optional) category: extensibility > toolchains team-Rules-Python Native rules for Python labels Nov 22, 2018
@philwo
Copy link
Member Author

philwo commented Nov 22, 2018

@brandjon Don't know if you're the right person to assign this to - if not, please reroute. :) Thank you!

@jerryzj
Copy link

jerryzj commented Nov 23, 2018

That's a very stupid bug. When I tried to build TensorFlow r1.12 with CUDA 10, I have to install the outdated python instead of python3...

@brandjon
Copy link
Member

I am the right person. I'll add this to the overall python mode tracking bug #6444. Note that due to #4815, even when the Python mode is set, Bazel doesn't select the "python3" alias in preference to "python".

@brandjon
Copy link
Member

FYI the solution to this will be that the default Python toolchain will verify the version of the Python runtime that it autodetects. Follow #7375 for progress on Python toolchain work.

@brandjon
Copy link
Member

I'm closing this as redundant with #4815 and #7375. When toolchains are enabled (--incompatible_use_python_toolchains, see #7899), the autodetecting toolchain (non-Windows platforms only) specifically checks that the python command it finds has the expected version. If there's a problem, you can either change your system installation of Python or define an explicit Python toolchain for your platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Python Native rules for Python type: bug
Projects
None yet
Development

No branches or pull requests

3 participants