GCloud 计算隧道始终显示警告,告知安装 numpy

问题描述 投票:0回答:2

我正在从远程计算机上使用 gcloud 设置隧道:

gcloud compute start-iap-tunnel ...

一切都曾经很好,直到几天前开始显示以下消息:

To increase the performance of the tunnel, consider installing NumPy. To install
NumPy, see: https://numpy.org/install/.
After installing NumPy, run the following command to allow gcloud to access
external packages:
  export CLOUDSDK_PYTHON_SITEPACKAGES=1

我完全按照它说的做了,我已经用

pip install numpy
安装了 numpy 并导出了变量,但是警告并没有消失。

你有过这样的经历吗?

python numpy gcloud ssh-tunnel
2个回答
3
投票

正如 @john-hanley 所提到的,这可能是由于 Python 安装在 Library 目录中,就像 macOS 通用安装的情况一样,并且 gcloud 按照 GCP 文档的建议安装在用户的主目录中。这可以通过重新安装 gcloud 或 python3 来解决。您可以通过在终端中运行来找到安装位置:

which gcloud
which python3

就我而言,将 gcloud 重新安装到 Library 更容易。唯一的缺点是我需要使用 sudo 运行组件安装:

sudo /Library/google-cloud-sdk/bin/gcloud components install ...

另一个原因可能是您使用的是 ZSH shell 而不是 Bash。 GCP 文档 提供了要添加到 .bashrc 文件中的命令,并注明除非添加,否则它仅在当前终端实例中有效。

就我而言,将 gcloud 重新安装到库并运行上述命令后,我在该特定选项卡中不再收到 NumPy 警告,但它出现在其他选项卡中。 我运行以下命令将该行添加到 Zsh:

echo "export CLOUDSDK_PYTHON_SITEPACKAGES=1" >> ~/.zshrc

警告消失了。我希望以上内容对其他人有帮助。 另请注意下面 @Jobu

的重要评论

0
投票

正如@Jobu 在上面的评论之一中提到的,您需要使用:

$(gcloud info --format="value(basic.python_location)") -m pip install numpy

如果再次收到警告,您可能需要为您的 shell 设置此环境变量:

export CLOUDSDK_PYTHON_SITEPACKAGES=1

如果您的 numpy 版本落后了,那么在这一切之后,警告可能仍然会出现。更新为:

$(gcloud info --format="value(basic.python_location)") -m pip install numpy --upgrade --break-system-packages
© www.soinside.com 2019 - 2024. All rights reserved.