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!
Advertisement
Answer
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 install 'cloud-sql-python-connector[pg8000]'