pip_import doesn't work with tensorflow
vertix opened this issue · comments
WORKSPACE
http_archive(
name = "io_bazel_rules_python",
sha256 = "0d1810fecc1bf2b6979d2af60e157d93d3004805bd8b7fda6eb52dda13480dca",
strip_prefix = "rules_python-115e3a0dab4291184fdcb0d4e564a0328364571a",
urls = ["https://github.com/bazelbuild/rules_python/archive/115e3a0.tar.gz"],
)
load("@io_bazel_rules_python//python:pip.bzl", "pip_import")
pip_import(
name = "pip",
requirements = "//:requirements.txt",
)
load("@pip//:requirements.bzl", "pip_install")
pip_install()
requirements.txt
tensorflow
BUILD
load("@io_bazel_rules_python//python:python.bzl", "py_binary")
load("@pip//:requirements.bzl", "requirement")
py_binary(
name = "test",
srcs = ["test.py"],
deps = [
requirement("tensorflow"),
],
)
test.py
import tensorflow as tf
if __name__ == "__main__":
pass
Raises:
ImportError: 'No module named tensorflow'
I can confirm. The tensorflow module is completely missing a tensorflow
directory after being installed as an external repo:
$ ls /private/var/tmp/_bazel_username/c896bd8ffa3b209834c1217c9406dcf0/external/pypi__tensorflow_1_7_0/
BUILD WORKSPACE tensorflow-1.7.0.data tensorflow-1.7.0.dist-info
+1, is there any progress on this issue?
+1
+1
Note that this is due to issue #92 . There's a workaround posted there for TensorFlow.
See https://groups.google.com/d/msg/bazel-sig-python/iQjV9sfSufw/qRtG3toDBAAJ -- short version: expect improvements to our Python rules in August.
Any movement on this? :)
Hi Justin, the movement is that I've taken over maintenance on Python-related issues, including rules_python, though I'm still getting a handle on priorities. Is this issue a regression or was it always broken?
I'm pretty sure the root cause (#92) has always existed.
It doesn't seem to have ever worked and it's kinda ironic that what is probably the most popular Bazel project can't be imported from another one through pip. Kinda steers you toward building it through Bazel. Not bad to increase adoption. (That's a silly joke, to be clear.)
To add more detail: we use TF both by using pip and compiling sources through a nested workspace, so we get to enjoy the worst of both worlds, when it comes to bugs. This issue is our worst pip headache, along with #96 (packages are fetched eagerly when first starting Bazel, rather than lazily when first using them).
+1
Yeah, I've just now run into this, too. Running a fork of rules_python to fix this doesn't seem like a great workaround
(I came to this after giving up on depending on tensorflow as a normal bazel extension, of course. They have that wild user-interaction-required ./configure script you seem to have to run that does a bunch of heuristics on your local filesystem to generate its own bazelrc file. Not great!)
I tried to get tensorflow to load with anaconda and conda. No success with Windows 10, using python 3.6 and 3.5. Any workaround for Windows without using Linux or Microsoft VS 20XX would be appreciated. https://anaconda.org was not of any use I could find.
C:\Users\Joe\Anaconda3\envs\tensorflow>conda install -c conda-forge tensorflow
Collecting package metadata: done
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
- tensorflow
Current channels:
- https://conda.anaconda.org/conda-forge/win-32
- https://conda.anaconda.org/conda-forge/noarch
- https://repo.anaconda.com/pkgs/main/win-32
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/free/win-32
- https://repo.anaconda.com/pkgs/free/noarch
- https://repo.anaconda.com/pkgs/r/win-32
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-32
- https://repo.anaconda.com/pkgs/msys2/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
Just wanted a heads up on whether the No module issue here similar to my issue here: #214
try our implementation here https://github.com/ali5h/rules_pip
+1, any updates?
We're working on incorporating the packaging code from rules_python_external
into rules_python
. rules_python_external
supports importing Tensorflow.
rules_python 0.1.0 has been released which upstreams the rules_python_external repo. Please switch from pip_import
to pip_install
which doesn't have this issue.