Closed
Description
I'm trying to use google-cloud-bigquery
, but my code fails to find bigquery
in google.cloud
.
I am able to import google.cloud
, but that loads pypi__google_cloud_core_0_28_0
only, and not the other dependencies that add to google.cloud
, despite pypi__google_cloud_bigquery_0_29_0
and all other transitive dependencies being in the runfiles.
Here is a debugging session:
In [22]: import google.cloud
In [23]: from google.cloud import bigquery
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~/firehook/cwm/bazel-bin/jupyter.runfiles/__main__/jupyter.py in <module>()
----> 1 from google.cloud import bigquery
ImportError: cannot import name 'bigquery'
In [24]: google.__spec__
Out[24]: ModuleSpec(name='google', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f2db22a6ef0>, origin='/home/fortuna/firehook/cwm/bazel-bin/jupyter.runfiles/pypi__google_cloud_core_0_28_0/google/__init__.py', submodule_search_locations=['/home/fortuna/firehook/cwm/bazel-bin/jupyter.runfiles/pypi__google_cloud_core_0_28_0/google'])
In [25]: google.cloud.__spec__
Out[25]: ModuleSpec(name='google.cloud', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f2db22a6eb8>, origin='/home/fortuna/firehook/cwm/bazel-bin/jupyter.runfiles/pypi__google_cloud_core_0_28_0/google/cloud/__init__.py', submodule_search_locations=['/home/fortuna/firehook/cwm/bazel-bin/jupyter.runfiles/pypi__google_cloud_core_0_28_0/google/cloud'])
In [26]: ! ls /home/fortuna/firehook/cwm/bazel-bin/jupyter.runfiles
__init__.py pypi__futures_3_2_0 pypi__google_resumable_media_0_3_1 pypi__requests_2_18_4
__main__ pypi__google_api_core_0_1_4 pypi__idna_2_6 pypi__rsa_3_4_2
MANIFEST pypi__googleapis_common_protos_1_5_3 pypi__protobuf_3_5_1 pypi__setuptools_38_4_0
pypi__cachetools_2_0_1 pypi__google_auth_1_3_0 pypi__pyasn1_0_4_2 pypi__six_1_11_0
pypi__certifi_2018_1_18 pypi__google_cloud_bigquery_0_29_0 pypi__pyasn1_modules_0_2_1 pypi__urllib3_1_22
pypi__chardet_3_0_4 pypi__google_cloud_core_0_28_0 pypi__pytz_2017_3
My BUILD rule is
py_binary(
name = "jupyter",
srcs = ["jupyter.py"],
data = [
requirement("google-cloud-bigquery"),
],
)
Where jupyter.py
starts an IPython REPL.