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

Repository '@python' is not defined #66203

Open
nmdesai22 opened this issue Apr 22, 2024 · 5 comments
Open

Repository '@python' is not defined #66203

nmdesai22 opened this issue Apr 22, 2024 · 5 comments
Assignees
Labels
subtype: ubuntu/linux Ubuntu/Linux Build/Installation Issues TF 2.16 type:build/install Build and install issues

Comments

@nmdesai22
Copy link

Issue type

Build/Install

Have you reproduced the bug with TensorFlow Nightly?

No

Source

source

TensorFlow version

2.16.1

Custom code

Yes

OS platform and distribution

Linux Ubuntu 22.04.1

Mobile device

No response

Python version

3.10.12

Bazel version

5.4.1

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

while building a tool with tensorflow v2.16.1, it gives build error as "The repository '@python' could not be resolved: Repository '@python' is not defined."

Standalone code to reproduce the issue

It seems issue is due to Hermatic Python from tensroflow 2.14.0 onwards. 
This commit creates the issue - https://github.com/tensorflow/tensorflow/commit/e85860e8382a460a0dd8547a536e5eaaf9096a9f

Reproduction env - TBD

Relevant log output

ERROR: /home/ronn/ronn_wrapper/BUILD:34:11: While resolving toolchains for target //ronn/ronn_wrapper:ronn_wrapper: invalid registered toolchain '@local_execution_config_python//:py_toolchain': error loading package '@local_execution_config_python//': Unable to find package for @python//:defs.bzl: The repository '@python' could not be resolved: Repository '@python' is not defined.
ERROR: Analysis of target '//ronn/ronn_wrapper:ronn_wrapper' failed; build aborted:
INFO: Elapsed time: 3.515s
@google-ml-butler google-ml-butler bot added the type:build/install Build and install issues label Apr 22, 2024
@tilakrayal tilakrayal added TF 2.16 subtype: ubuntu/linux Ubuntu/Linux Build/Installation Issues labels Apr 22, 2024
@tilakrayal
Copy link
Contributor

@nmdesai22,
Could you please provide the steps you are following to install the tensorflow and also provide the complete error log which helps to debug the issue in an effective way. Thank you!

@tilakrayal tilakrayal added the stat:awaiting response Status - Awaiting response from author label Apr 23, 2024
@nmdesai22
Copy link
Author

  • I am using bazel (v5.4.1) to download tensorflow and build the project.
  • I declare TF version in a WORKSPACE file of the project.
http_archive(
    name = "org_tensorflow",
    strip_prefix = "tensorflow-2.16.1",
    sha256 = "54c976f828182f85e10e03840dd3b0504109f57760a498075574e35e9aa983fe",
    urls = [
        "https://github.com/tensorflow/tensorflow/archive/v2.16.1.zip"
    ],
)

Then , give below command to buiild project

bazel build --subcommands --verbose_failures --config android_arm64 -c opt ronn/ronn_wrapper:ronn_wrapper

I get below Log on the terminal

DEBUG: /home/user.dave/.cache/bazel/_bazel_user.dave/930ed5452c6d7a47881f9fd479f92e3f/external/org_tensorflow/third_party/repo.bzl:132:14:
Warning: skipping import of repository 'com_google_protobuf' because it already exists.
DEBUG: /home/user.dave/.cache/bazel/_bazel_user.dave/930ed5452c6d7a47881f9fd479f92e3f/external/org_tensorflow/third_party/repo.bzl:132:14:
Warning: skipping import of repository 'zlib' because it already exists.
ERROR: /home/user.dave/workspace/GIT_REPO/Google_io/tflite_ronn_project/ronn/ronn_wrapper/BUILD:34:11: While resolving toolchains for target //ronn/ronn_wrapper:ronn_wrapper: invalid registered toolchain '@local_execution_config_python//:py_toolchain': error loading package '@local_execution_config_python//': Unable to find package for @python//:defs.bzl: The repository '@python' could not be resolved: Repository '@python' is not defined.
ERROR: Analysis of target '//ronn/ronn_wrapper:ronn_wrapper' failed; build aborted:
INFO: Elapsed time: 0.112s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
    currently loading: @local_execution_config_python//
    Fetching @local_jdk; fetching
+ rm -rf /tmp/tmp.JBqcj6caTS

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Status - Awaiting response from author label Apr 23, 2024
@nmdesai22
Copy link
Author

Update -

As a Temporary fix, I added python definitions in my Project's {project}/WORKSPACE file, and it worked. and Project can be build succesfully

I added below additional changes in WORKSPACE.

# bazel_skylib and rules_python are from @org_tensorflow/WORKSPACE.
# Remove them once https://github.com/tensorflow/tensorflow/issues/66203 is fixed.
http_archive(
    name = "bazel_skylib",
    sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
    urls = [
        "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
        "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
    ],
)

http_archive(
    name = "rules_python",
    sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b",
    strip_prefix = "rules_python-0.26.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.26.0/rules_python-0.26.0.tar.gz",
)

# Copied from `@org_tensorflow//:WORKSPACE`.
#remove these definitions once https://github.com/tensorflow/tensorflow/issues/66203 is fixed.
load(
    "@rules_python//python:repositories.bzl",
    "py_repositories",
    "python_register_toolchains",
)
py_repositories()

load(
    "@org_tensorflow//tensorflow/tools/toolchains/python:python_repo.bzl",
    "python_repository",
)
python_repository(name = "python_version_repo")
load("@python_version_repo//:py_version.bzl", "HERMETIC_PYTHON_VERSION")

# Toolchain setup here is to please the TF workspace scripts,
# and we do not use this Python version to build pip packages.
python_register_toolchains(
    name = "python",
    ignore_root_user_error = True,
    python_version = HERMETIC_PYTHON_VERSION,
)

@tilakrayal
Copy link
Contributor

@nmdesai22,
Could you please try to run bazel clean --expunge to make sure old bazel files are deleted? and then run the build command again.
If you still get an error try the command in the image to make sure 'location to python.exe' is recognized as executable

image

If it still does not work, please try to follow the steps below

Click to expand! Step1: Install Python 3.10 in C:\

Step2: Create and activate Virtual env
C:\python39\python.exe -m venv venv39_new
D:\user\venv39_new\scripts\activate ==>
(venv39_new) D:\user\

Step3: git clone https://github.com/tensorflow/tensorflow.git==>(venv39_new) D:\user\tensorflow>

Step4: Set up all the paths and files

set BAZEL_SH=C:\msys64\usr\bin\bash.exe

set BAZEL_VS=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools

set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC

set PATH=c:\Tools\Bazel;D:\user\venv39_new\Scripts;C:\Program Files\Python39\Scripts\

set PYTHON_BIN_PATH=D:/user/venv39_new/Scripts/python.exe
set PYTHON_LIB_PATH=D:/user/venv39_new/lib/site-packages
set PYTHON_DIRECTORY=D:/user/venv39_new/Scripts/

Thank you!

@tilakrayal tilakrayal added the stat:awaiting response Status - Awaiting response from author label Apr 30, 2024
@nmdesai22
Copy link
Author

I am using Linux ENV to build the project. I did try all three suggestions, but get the same error

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Status - Awaiting response from author label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subtype: ubuntu/linux Ubuntu/Linux Build/Installation Issues TF 2.16 type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests

2 participants