如何确保PromptSession导入或以其他方式解决

如何确保PromptSession导入或以其他方式解决

本文介绍了登录到GCP SQL:如何确保PromptSession导入或以其他方式解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Cloud Shell更新一些用户权限. 我正在使用gcloud sql connect my-instance --user=root

I am trying to use the Cloud Shell to update some user permissions. I am logging in using gcloud sql connect my-instance --user=root

gcloud sql connect my-instance
Whitelisting your IP for incoming connection for 5 minutes...done.
Connecting to database with SQL user [sqlserver].********************************************************************************
Python command will soon point to Python v3.7.3.
Python 2 will be sunsetting on January 1, 2020.
See http://https://www.python.org/doc/sunset-python-2/
Until then, you can continue using Python 2 at /usr/bin/python2, but soon
/usr/bin/python symlink will point to /usr/local/bin/python3.
To suppress this warning, create an empty ~/.cloudshell/no-python-warning file.
The command will automatically proceed in  seconds or on any key.
********************************************************************************
> Password:
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/mssqlcli/main.py", line 117, in <module>
    main()
  File "/usr/local/lib/python2.7/dist-packages/mssqlcli/main.py", line 110, in main
    run_cli_with(mssqlcli_options)
  File "/usr/local/lib/python2.7/dist-packages/mssqlcli/main.py", line 43, in run_cli_with
    from mssqlcli.mssql_cli import MssqlCli
  File "/usr/local/lib/python2.7/dist-packages/mssqlcli/mssql_cli.py", line 18, in <module>
    from prompt_toolkit.shortcuts import PromptSession, CompleteStyle
ImportError: cannot import name PromptSession

A)我已经将root用户的密码设置得如此不安全和容易,所以我根本不会弄错它.

A) I have made the root user's password so insecure and easy there is no way I am mistyping it.

B)现在是一月的三号,所以我真的不知道这个Python版本错误是关于什么的.我制作了文件,但FYI ~/.cloudshell不存在,因此我必须先制作它.即使这样,它只是抑制了版本警告,当我尝试登录时,主要错误仍然存​​在.

B) It is the third of January, so I really don't know what this Python version error is on about. I made the file but FYI ~/.cloudshell did not exist so I had to make it first. Even so, it just suppresses the version warning, the main error persists when I try to log in.

文档确认还有两次登录glcoud beta sql connect的方法,但这又给我另一个错误

The documentation acknowledges there are a couple other login methods using glcoud beta sql connect, but that gets me another error

2020/01/04 18:38:41 Rlimits for file descriptors set to {&{8500 1048576}}
2020/01/04 18:38:41 invalid json file "/tmp/tmp.s38C662KKr/legacy_credentials/[email protected]/adc.json": open /tmp/tmp.s38C662KKr/legacy_credentials/[email protected]/adc.json: no such file or directory
ERROR: (gcloud.beta.sql.connect) Failed to start the Cloud SQL Proxy.

alpha相同.

这是我在Cloud Shell中输入的第一件事,所以我无法想象是什么破坏了PromptSession.

This is the first thing I have typed into Cloud Shell, so I can't imagine what could have broken PromptSession.

推荐答案

尝试从Cloud Shell连接时最有可能出现问题(我使用此命令设法从Compute Engine实例连接);可能与Python运行时/环境变量有关.据报道此处.工程知道并且正在研究它.

There most likely is an issue while attempting to connect from the Cloud Shell (I managed to connect from a Compute Engine instance with this command); possibly related to the Python run-time / environment variable. It has been reported here. Engineering is aware and are looking into it.

这篇关于登录到GCP SQL:如何确保PromptSession导入或以其他方式解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 18:20