3

When I was going through the Google Cloud tutorial: https://cloud.google.com/python/getting-started/using-pub-sub#running_the_app_on_your_local_machine

I got the following error:

google.auth._default No project ID could be determined from the Cloud SDK configuration. Consider running gcloud config set project or setting the GOOGLE_CLOUD_PROJECT environment variable

I did 'gcloud config set project [my project name]' with no success.

What's the problem?

Update: I've deployed app engines previously without any problem. The problem only happens when I run the psqworker for this Pub/Sub function. I know my project ID and used it before.

rara
  • 29
  • 1
  • 1
  • 6

3 Answers3

5

The first thing I would try would be:

gcloud info

This will tell you the account and project that gcloud is currently set to.

You may also find the available projects for your account with the following gcloud command:

gcloud projects list

KevinG
  • 450
  • 3
  • 8
1

Locate the project ID and project number

There are two ways to identify your project: the project number and project ID.

The project number is automatically assigned when you create a project.

The project ID is a unique identifier for a project. When you first create a project, you can accept the default generated project ID or create your own. A project ID cannot be changed after the project is created, so if you are creating a new project, be sure to choose an ID that you'll be comfortable using for the lifetime of the project.

Note: You should be aware that some resource identifiers (such as project IDs) might be retained beyond the life of your project. For this reason, avoid storing sensitive information in resource identifiers.

To locate your project ID and project number:

  1. Go to the Cloud Platform Console
  2. From the projects list, select the name of your project.
  3. On the left, click Dashboard. The project name and ID are displayed in the Dashboard.
LuFFy
  • 8,799
  • 10
  • 41
  • 59
-1

TL;DR Use virtualenv -p C:/Python27/python.exe name-of-env instead of virtualenv -p C:/Python36/python.exe name-of-env in the tutorial

I ran into a similar issue. Here are the steps I went through and why. Hope it helps!

First I tried to specify the id with the command gcloud config set project name-of-your-project This resulted in the error

ERROR: Python 3 and later is not compatible with by the Google Cloud SDK. Please use a Python 2.7.x version.

If you have a compatible Python interpreter installed, you can use it by setting
the CLOUDSDK_PYTHON environment variable to point to it.

I thought this error was weird because the tutorial tells you to use python3 but it doesn't work. So I created a virtualenv with python2.7 like so

virtualenv -p C:/Python27/python.exe name-of-env (I have python 2 and 3 so its easier to specify the whole path to the .exe file)

Then follow the rest of the tutorial with

name-of-env\scripts\activate
pip install -r requirements.txt

Don't know why you have to use python3 when it doesn't even work.

Brian Sunbury
  • 45
  • 2
  • 9