HTTP 401 with wrong environment us-west1-gcp

This Python code:

pinecone.init(api_key=PINECONE_API_KEY, enviroment=PINECONE_ENV)
pinecone.whoami()

generates this error:

HTTPError: ('401 Client Error: Unauthorized for url: https://controller.us-west1-gcp.pinecone.io/actions/whoami', 'API key is missing or invalid for the environment "us-west1-gcp". Check that the correct environment is specified.')

I’ve confirmed my API key is correct, and PINECONE_ENV=us-west1-gcp-free , yet note the environment it is complaining about is us-west1-gcp.

Okay so if I del those two variables and call pinecone.init with hard-coded values, it seems like it works. It doesn’t work if I change variable names to something like PINECONE_API_KEY_VAR and PINECONE_ENV_VAR

If I load these into the environment and reference via

pinecone.init(api_key=os.environ['PINECONE_API_KEY'], environment=os.environ['PINECONE_ENV'])

it works. So basically, it looks like pinecone.init needs to either take hard-coded literals in the arguments to api_key and environment, or it needs to reference them from os.environment. For some reason, it doesn’t seem to like these as variables, at least as I’m defining them…