在Python 3.7中安装Cloud-Sql-Python-Connector [PG8000]的错误
我正在尝试通过我本地计算机通过Python 3.7连接到云SQL SQL SQL PostgreSQL实例。我正在遵循readme
pip install cloud-sql-python-connector[pg8000]
但是,当我在终端中运行它时,我会收到以下错误:
zsh: no matches found: cloud-sql-python-connector[pg8000]
确实存在软件包conder> cloud> cloud-sql-sql-sql-python-connector < 建立连接的部分,因为
pg8000
未定义:
def getconn() -> pg8000.connections.Connection:
conn: pg8000.connections.Connection = connector.connect(
"project:region:instance",
"pg8000",
user="postgres",
password="XXXXXXXX",
db="your-db-name"
)
return conn
/code>没有[PG8000]
与之关联的部分,但是我无法运行下一个 我可能做错了什么,将不胜感激!
I am trying to connect to a Cloud SQL postgresql instance through python 3.7 from my local machine. I am following the guide from the README cloud-sql-python-connector. There it says to pip install the necessary module with the following command, for a postgresql instance:
pip install cloud-sql-python-connector[pg8000]
But when I run this in my terminal, I get the following error:
zsh: no matches found: cloud-sql-python-connector[pg8000]
There does exist the package cloud-sql-python-connector
without the [pg8000]
part associated to it, but then I can't run the next part establishing a connection, because pg8000
is not defined:
def getconn() -> pg8000.connections.Connection:
conn: pg8000.connections.Connection = connector.connect(
"project:region:instance",
"pg8000",
user="postgres",
password="XXXXXXXX",
db="your-db-name"
)
return conn
Any advice on what I might be doing wrong would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来这实际上是 Mac 用户的 zsh 终端长期存在的问题。它不喜欢使用方括号进行 pip 安装。请参阅详细信息
如上所述,转义方括号是可行的,因此以下内容也应该如此:
It seems this is actually a long-running issue with the zsh terminal for mac users. It doesn't like pip installs with the square brackets. See details here
As mentioned escaping the square brackets works and so should the following:
最后,我需要做的就是逃脱PIP安装命令中的方括号。这是因为方括号被解释为命令行上的模式( a>)。因此,最终的命令是:
我仍然是终端的新手,但希望这对其他遇到此类问题的人有帮助。
In the end all I needed to do was escape the square brackets in the pip install command. This is because square brackets are interpreted as a pattern on the command line (article). So the final command that worked was:
I'm still new to the terminal, but hopefully this helps anyone else having such problems.