Google Cloud SDK install failed UnicodeDecodeError: 'ascii' codec
Google Cloud SDK install failed UnicodeDecodeError: 'ascii' codec
在我的 Windows 10 计算机上安装 Google Cloud SDK 时出现以下错误:
ERROR: gcloud failed to load: 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in range(128)
gcloud_main = _import_gcloud_main()
import googlecloudsdk.gcloud_main
from googlecloudsdk.calliope import cli
from googlecloudsdk.calliope import backend
from googlecloudsdk.calliope import parser_extensions
from googlecloudsdk.core.updater import update_manager
from googlecloudsdk.core.updater import installers
from googlecloudsdk.core.credentials import store
from googlecloudsdk.core.credentials import creds
from googlecloudsdk.core.credentials import devshell as c_devshell
from oauth2client import client
from oauth2client import crypt
from oauth2client import _openssl_crypt
from OpenSSL import crypto
from OpenSSL import crypto, SSL
from cryptography import x509
from cryptography.x509.base import (
from cryptography.x509.extensions import Extension, ExtensionType
from asn1crypto.keys import PublicKeyInfo
from ._elliptic_curve import (
from ._int import inverse_mod
from ._perf._big_num_ctypes import libcrypto
libcrypto_path = find_library('crypto')
fname = os.path.join(directory, name)
result_path = result_path + p_path
This usually indicates corruption in your gcloud installation or problems with your Python interpreter.
Please verify that the following is the path to a working Python 2.7 executable:
C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\python.exe
If it is not, please set the CLOUDSDK_PYTHON environment variable to point to a working Python 2.7 executable.
If you are still experiencing problems, please reinstall the Cloud SDK using the instructions here:
https://cloud.google.com/sdk/
Traceback (most recent call last):
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\bin\bootstrapping\install.py", line 12, in <module>
import bootstrapping
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\bin\bootstrapping\bootstrapping.py", line 44, in <module>
from googlecloudsdk.core.credentials import store as c_store
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\lib\googlecloudsdk\core\credentials\store.py", line 35, in <module>
from googlecloudsdk.core.credentials import creds
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\lib\googlecloudsdk\core\credentials\creds.py", line 34, in <module>
from googlecloudsdk.core.credentials import devshell as c_devshell
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\lib\googlecloudsdk\core\credentials\devshell.py", line 30, in <module>
from oauth2client import client
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\lib\third_party\oauth2client\client.py", line 51, in <module>
from oauth2client import crypt
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\lib\third_party\oauth2client\crypt.py", line 45, in <module>
from oauth2client import _openssl_crypt
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\lib\third_party\oauth2client\_openssl_crypt.py", line 16, in <module>
from OpenSSL import crypto
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\OpenSSL\crypto.py", line 12, in <module>
from cryptography import x509
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\cryptography\x509\__init__.py", line 9, in <module>
from cryptography.x509.base import (
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\cryptography\x509\base.py", line 16, in <module>
from cryptography.x509.extensions import Extension, ExtensionType
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\cryptography\x509\extensions.py", line 13, in <module>
from asn1crypto.keys import PublicKeyInfo
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\asn1crypto\keys.py", line 22, in <module>
from ._elliptic_curve import (
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\asn1crypto\_elliptic_curve.py", line 51, in <module>
from ._int import inverse_mod
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\asn1crypto\_int.py", line 56, in <module>
from ._perf._big_num_ctypes import libcrypto
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\asn1crypto\_perf\_big_num_ctypes.py", line 31, in <module>
libcrypto_path = find_library('crypto')
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\ctypes\util.py", line 53, in find_library
fname = os.path.join(directory, name)
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\ntpath.py", line 85, in join
result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in range(128)
Failed to install.
我尝试重新下载安装程序,我 运行 它具有管理员权限,并且我选择了一个没有任何非 ASCII 字符或空格的安装文件夹。
我还验证了安装程序已成功设置 python,更具体地说,我在 C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\python.exe
有 Python 版本 2.7.13
我也曾尝试设置 CLOUDSDK_PYTHON
变量但没有成功。
注意:我看到了这个,但是我有一个不同版本的cloud-sdk (213.0.0),我没有在我的代码中找到提到的部分,所以我没有认为这是一个重复的问题。
编辑 1:
我的 ntpath.py 第 63-90 行:
def join(path, *paths):
"""Join two or more pathname components, inserting "\" as needed."""
result_drive, result_path = splitdrive(path)
for p in paths:
p_drive, p_path = splitdrive(p)
if p_path and p_path[0] in '\/':
# Second path is absolute
if p_drive or not result_drive:
result_drive = p_drive
result_path = p_path
continue
elif p_drive and p_drive != result_drive:
if p_drive.lower() != result_drive.lower():
# Different drives => ignore the first path entirely
result_drive = p_drive
result_path = p_path
continue
# Same drive in different case
result_drive = p_drive
# Second path is relative to the first
if result_path and result_path[-1] not in '\/':
result_path = result_path + '\'
result_path = result_path + p_path #85
## add separator between UNC and non-absolute path
if (result_path and result_path[0] not in '\/' and
result_drive and result_drive[-1:] != ':'):
return result_drive + sep + result_path
return result_drive + result_path
编辑 2:
感谢您的建议我也检查了这些 SO 问题和答案,但找不到解决方案:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 13: ordinal not in range(128)
请注意,我在 gcloud 路径中没有任何非 ascii 字符,我已使用以下命令检查过它:gci -recurse . | where {$_.Name -match "[^\u0000-\u007F]"}
还有其他解决方法吗?
只是要尝试的事情的列表:
从 https://www.python.org/downloads/release/python-2715/ 安装 Python。记住 python
二进制文件的位置。将其设置为 CLOUDSDK_PYTHON
显示带有变量集的打印输出。
确保变量真的设置了。
在C:\
(或C:\AndroidSdk
,但最好是C:\
):运行gci
命令在https://superuser.com/questions/237533/find-files-with-non-ascii-characters-in-filenames-in-windows-xp,显示输出。或者 运行 来自同一个问题的 python 程序。
会被4.找到,但是第13个字符好像是\
。尝试重新创建目录,给AndroidSDK
一个shorter/longer名字,看看是否还是第13个字符
我刚刚遇到了同样的问题,我花了一段时间才解决它,所以这是我对后代的发现:
我安装了 npm 包 windows-build-tools(使用 npm install --global windows-build-tools
),并且该包显然带有一个单独的 Python 安装在 C:\Users\ [my user]\.windows-build-tools 我忘记了。该文件夹也在我的路径中。
不幸的是,我的 Windows 用户名包含非 ASCII 字符。据我所知,我无法更改此设置,因为我的用户绑定到我的雇主管理的 MS 帐户。
尽管我将 SDK 安装在一个没有问题的位置 (D:\CloudSDK) 并将 CLOUDSDK_PYTHON 设置为另一个 Python 2.7.15 安装,我一直收到问题中描述的错误,直到我删除了 windows 构建工具 python 安装以及我发现并重新安装 2.7.15 之前任何其他 Python 安装的痕迹。然后,我在没有捆绑 Python 的情况下重试了 Cloud SDK 安装,并使用了 PATH 中的全新安装,这解决了问题。
也许这对某人有帮助。
非 ascii 字符也有同样的问题。我编辑了安装根文件夹中的 cloud_env.bat
(我的是 C:\prg\GCP
)并删除了附加的 %PATH%
(见下文)- 安装问题已解决。
我还不得不将此手册添加到 install:
C:\prg\GCP\google-cloud-sdk\bin;C:\prg\GCP\google-cloud-sdk\platform\bundledpython\
之后的 PATH
;
并更新 USERPROFILE=C:\prg\GCP
(我的包含非 ascii)。
cloud_env.bat
ECHO OFF
CLS
REM SET PATH=C:\prg\GCP\google-cloud-sdk\bin;%PATH%;
SET PATH=C:\prg\GCP\google-cloud-sdk\bin;
cd C:\prg\GCP
ECHO Welcome to the Google Cloud SDK! Run "gcloud -h" to get the list of available commands.
ECHO ---
ECHO ON`
对我来说,window10,
这是因为 python 2.7 路径在 python 3.7 之前找到,
我干脆删掉2.7 PATH
和 SET CLOUDSDK_PYTHON 指向 3.7 路径并且有效。
在我的 Windows 10 计算机上安装 Google Cloud SDK 时出现以下错误:
ERROR: gcloud failed to load: 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in range(128)
gcloud_main = _import_gcloud_main()
import googlecloudsdk.gcloud_main
from googlecloudsdk.calliope import cli
from googlecloudsdk.calliope import backend
from googlecloudsdk.calliope import parser_extensions
from googlecloudsdk.core.updater import update_manager
from googlecloudsdk.core.updater import installers
from googlecloudsdk.core.credentials import store
from googlecloudsdk.core.credentials import creds
from googlecloudsdk.core.credentials import devshell as c_devshell
from oauth2client import client
from oauth2client import crypt
from oauth2client import _openssl_crypt
from OpenSSL import crypto
from OpenSSL import crypto, SSL
from cryptography import x509
from cryptography.x509.base import (
from cryptography.x509.extensions import Extension, ExtensionType
from asn1crypto.keys import PublicKeyInfo
from ._elliptic_curve import (
from ._int import inverse_mod
from ._perf._big_num_ctypes import libcrypto
libcrypto_path = find_library('crypto')
fname = os.path.join(directory, name)
result_path = result_path + p_path
This usually indicates corruption in your gcloud installation or problems with your Python interpreter.
Please verify that the following is the path to a working Python 2.7 executable:
C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\python.exe
If it is not, please set the CLOUDSDK_PYTHON environment variable to point to a working Python 2.7 executable.
If you are still experiencing problems, please reinstall the Cloud SDK using the instructions here:
https://cloud.google.com/sdk/
Traceback (most recent call last):
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\bin\bootstrapping\install.py", line 12, in <module>
import bootstrapping
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\bin\bootstrapping\bootstrapping.py", line 44, in <module>
from googlecloudsdk.core.credentials import store as c_store
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\lib\googlecloudsdk\core\credentials\store.py", line 35, in <module>
from googlecloudsdk.core.credentials import creds
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\lib\googlecloudsdk\core\credentials\creds.py", line 34, in <module>
from googlecloudsdk.core.credentials import devshell as c_devshell
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\lib\googlecloudsdk\core\credentials\devshell.py", line 30, in <module>
from oauth2client import client
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\lib\third_party\oauth2client\client.py", line 51, in <module>
from oauth2client import crypt
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\lib\third_party\oauth2client\crypt.py", line 45, in <module>
from oauth2client import _openssl_crypt
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\lib\third_party\oauth2client\_openssl_crypt.py", line 16, in <module>
from OpenSSL import crypto
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\OpenSSL\crypto.py", line 12, in <module>
from cryptography import x509
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\cryptography\x509\__init__.py", line 9, in <module>
from cryptography.x509.base import (
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\cryptography\x509\base.py", line 16, in <module>
from cryptography.x509.extensions import Extension, ExtensionType
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\cryptography\x509\extensions.py", line 13, in <module>
from asn1crypto.keys import PublicKeyInfo
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\asn1crypto\keys.py", line 22, in <module>
from ._elliptic_curve import (
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\asn1crypto\_elliptic_curve.py", line 51, in <module>
from ._int import inverse_mod
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\asn1crypto\_int.py", line 56, in <module>
from ._perf._big_num_ctypes import libcrypto
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\site-packages\asn1crypto\_perf\_big_num_ctypes.py", line 31, in <module>
libcrypto_path = find_library('crypto')
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\ctypes\util.py", line 53, in find_library
fname = os.path.join(directory, name)
File "C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\lib\ntpath.py", line 85, in join
result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in range(128)
Failed to install.
我尝试重新下载安装程序,我 运行 它具有管理员权限,并且我选择了一个没有任何非 ASCII 字符或空格的安装文件夹。
我还验证了安装程序已成功设置 python,更具体地说,我在 C:\AndroidSdk\CloudSdk\google-cloud-sdk\platform\bundledpython\python.exe
有 Python 版本 2.7.13我也曾尝试设置 CLOUDSDK_PYTHON
变量但没有成功。
注意:我看到了这个
编辑 1:
我的 ntpath.py 第 63-90 行:
def join(path, *paths):
"""Join two or more pathname components, inserting "\" as needed."""
result_drive, result_path = splitdrive(path)
for p in paths:
p_drive, p_path = splitdrive(p)
if p_path and p_path[0] in '\/':
# Second path is absolute
if p_drive or not result_drive:
result_drive = p_drive
result_path = p_path
continue
elif p_drive and p_drive != result_drive:
if p_drive.lower() != result_drive.lower():
# Different drives => ignore the first path entirely
result_drive = p_drive
result_path = p_path
continue
# Same drive in different case
result_drive = p_drive
# Second path is relative to the first
if result_path and result_path[-1] not in '\/':
result_path = result_path + '\'
result_path = result_path + p_path #85
## add separator between UNC and non-absolute path
if (result_path and result_path[0] not in '\/' and
result_drive and result_drive[-1:] != ':'):
return result_drive + sep + result_path
return result_drive + result_path
编辑 2:
感谢您的建议我也检查了这些 SO 问题和答案,但找不到解决方案:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 13: ordinal not in range(128)
请注意,我在 gcloud 路径中没有任何非 ascii 字符,我已使用以下命令检查过它:gci -recurse . | where {$_.Name -match "[^\u0000-\u007F]"}
还有其他解决方法吗?
只是要尝试的事情的列表:
从 https://www.python.org/downloads/release/python-2715/ 安装 Python。记住
python
二进制文件的位置。将其设置为CLOUDSDK_PYTHON
显示带有变量集的打印输出。
确保变量真的设置了。
在
C:\
(或C:\AndroidSdk
,但最好是C:\
):运行gci
命令在https://superuser.com/questions/237533/find-files-with-non-ascii-characters-in-filenames-in-windows-xp,显示输出。或者 运行 来自同一个问题的 python 程序。会被4.找到,但是第13个字符好像是
\
。尝试重新创建目录,给AndroidSDK
一个shorter/longer名字,看看是否还是第13个字符
我刚刚遇到了同样的问题,我花了一段时间才解决它,所以这是我对后代的发现:
我安装了 npm 包 windows-build-tools(使用 npm install --global windows-build-tools
),并且该包显然带有一个单独的 Python 安装在 C:\Users\ [my user]\.windows-build-tools 我忘记了。该文件夹也在我的路径中。
不幸的是,我的 Windows 用户名包含非 ASCII 字符。据我所知,我无法更改此设置,因为我的用户绑定到我的雇主管理的 MS 帐户。
尽管我将 SDK 安装在一个没有问题的位置 (D:\CloudSDK) 并将 CLOUDSDK_PYTHON 设置为另一个 Python 2.7.15 安装,我一直收到问题中描述的错误,直到我删除了 windows 构建工具 python 安装以及我发现并重新安装 2.7.15 之前任何其他 Python 安装的痕迹。然后,我在没有捆绑 Python 的情况下重试了 Cloud SDK 安装,并使用了 PATH 中的全新安装,这解决了问题。
也许这对某人有帮助。
非 ascii 字符也有同样的问题。我编辑了安装根文件夹中的 cloud_env.bat
(我的是 C:\prg\GCP
)并删除了附加的 %PATH%
(见下文)- 安装问题已解决。
我还不得不将此手册添加到 install:
C:\prg\GCP\google-cloud-sdk\bin;C:\prg\GCP\google-cloud-sdk\platform\bundledpython\
之后的 PATH
;
并更新 USERPROFILE=C:\prg\GCP
(我的包含非 ascii)。
cloud_env.bat
ECHO OFF
CLS
REM SET PATH=C:\prg\GCP\google-cloud-sdk\bin;%PATH%;
SET PATH=C:\prg\GCP\google-cloud-sdk\bin;
cd C:\prg\GCP
ECHO Welcome to the Google Cloud SDK! Run "gcloud -h" to get the list of available commands.
ECHO ---
ECHO ON`
对我来说,window10,
这是因为 python 2.7 路径在 python 3.7 之前找到,
我干脆删掉2.7 PATH
和 SET CLOUDSDK_PYTHON 指向 3.7 路径并且有效。