简体   繁体   English

如何在colab中安装bazel?

[英]How to install bazel in colab?

I want to use bazel builder for some project in colab.我想在 colab 中为某个项目使用 bazel builder。 But !bazel gives me /bin/bash: bazel: command not found .但是!bazel给了我/bin/bash: bazel: command not found I tried to install it with我试着安装它

BAZEL_VERSION = '0.20.0'

!wget https://github.com/bazelbuild/bazel/releases/download/{BAZEL_VERSION}/bazel-{BAZEL_VERSION}-installer-linux-x86_64.sh

!chmod +x bazel-{BAZEL_VERSION}-installer-linux-x86_64.sh

# !export PATH="$PATH:$HOME/bin:/root/bin"

But it didn't help.但这没有帮助。 How should I install it?我应该如何安装它?

Use these commands:使用这些命令:

!apt install apt-transport-https curl gnupg
!curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
!mv bazel.gpg /etc/apt/trusted.gpg.d/
!echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
!apt update && apt install bazel

The simplest way:最简单的方法:

!npm install -g @bazel/bazelisk

npm is already installed by default in Colab. npm已默认安装在 Colab 中。 I just tested the above code and it works fine.我刚刚测试了上面的代码,它工作正常。 More info: https://github.com/bazelbuild/bazelisk更多信息: https://github.com/bazelbuild/bazelisk

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM