Skip to content

can't load modules on python2/3 container #40

@cristifalcas

Description

@cristifalcas

WORKSPACE stuff:

pip_repository(
    name = "requirements_py3",
    python_interpreter = "python3",
    requirements = "//lib/kubernetes:requirements.lock.txt",
)

I have this defined in my BUILD:

# Image for the API
py3_image(
    name = "api_docker",
    srcs = [":api"],
    base = ":python3.7_image",
    main = "main.py",
    visibility = ["//visibility:public"],
)

py_binary(
    name = "api",
    srcs = glob(
        ["*.py"],
    ),
    main = "main.py",
    python_version = "PY3",
    srcs_version = "PY3",
    deps = [
        "//lib/kubernetes:kubernetes_util",
        "@requirements_py3//docopt",
        "@requirements_py3//dulwich",
        "@requirements_py3//flask",
        "@requirements_py3//gevent",
        "@requirements_py3//prometheus_client",
    ],
)

The first thing in main.py is

from gevent import monkey
monkey.patch_all()

When I try to bazel run the docker image, I get this:

Traceback (most recent call last):
  File "/app/apps/switchboard/api/api_docker.binary.runfiles/com_something/apps/switchboard/api/main.py", line 10, in <module>
    from gevent import monkey
ImportError: cannot import name 'monkey' from 'gevent' (/app/apps/switchboard/api/api_docker.binary.runfiles/requirements_py3/gevent/__init__.py)

The application works as expected when running the py_binary with bazel run

Any known issues regarding using a container with pip_repository?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions