[英]kubectl pyenv python version conflict
我試圖在Mac上運行一些kubectl命令,在這里我使用pyenv來管理python版本。 每當我運行某些kubectl命令時,都會導致錯誤,其中kubectl指出找不到python2命令。
josh@venus:~/pjx/distribut_io ❯ kubectl get pods
Unable to connect to the server: error executing access token command "/Users/josh/google-cloud-sdk/bin/gcloud config config-helper --format=json": err=exit status 127 output= stderr=pyenv: python2: command not found
The `python2' command exists in these Python versions:
2.7.4
fp
josh@venus:~/pjx/distribut_io ❯ which python
/Users/josh/.pyenv/shims/python
josh@venus:~/pjx/distribut_io ❯ which python2
/Users/josh/.pyenv/shims/python2
我嘗試將.python-version
更改為2.7.4,系統和其他幾個版本,但似乎無法正常工作。 我迫切需要穿線,有人可以提供指導嗎?
kubectl不需要Python,但是gcloud需要。
這是gcloud源代碼的一部分(實際上是用bash編寫的):
# CLOUDSDK_ROOT_DIR (a) installation root dir
# CLOUDSDK_PYTHON (u) python interpreter path
# CLOUDSDK_PYTHON_ARGS (u) python interpreter arguments
# CLOUDSDK_PYTHON_SITEPACKAGES (u) use python site packages
...
# Cloud SDK requires python 2.7
case $CLOUDSDK_PYTHON in
*python2*)
;;
*python[0-9]*)
CLOUDSDK_PYTHON=
;;
esac
# if CLOUDSDK_PYTHON is empty
if [ -z "$CLOUDSDK_PYTHON" ]; then
# if python2 exists then plain python may point to a version != 2
if which python2 >/dev/null; then
CLOUDSDK_PYTHON=python2
elif which python2.7 >/dev/null; then
# this is what some OS X versions call their built-in Python
CLOUDSDK_PYTHON=python2.7
else
CLOUDSDK_PYTHON=python
fi
fi
因此,檢查環境變量以了解啟動gcloud時發生的情況。
作為一個簡單的解決方法,您可以使用自制軟件安裝python2,也可以僅創建一個symlink python2-> python:
sudo ln -s `which python` $(dirname `which python`)/python2
另一種方法是按照pyenv文檔中的說明配置pyenv設置,以獲取必要的python版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.