question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Project was not passed" error, even though ran

See original GitHub issue

I attempted to follow the setup instructions and ran into an odd error. The instructions I was following are here: https://googlecloudplatform.github.io/gcloud-python/stable/gcloud-auth.html

Here is what I attempted:

  1. virtualenv ~/venv
  2. source ~/venv/bin/activate
  3. pip install gcloud
  4. gcloud auth login
  5. python
>>> from gcloud import pubsub
>>> pubsub.Client()

Here’s the error I received when I ran pubsub.Client()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../venv/local/lib/python2.7/site-packages/gcloud/client.py", line 184, in __init__
    _ClientProjectMixin.__init__(self, project=project)
  File ".../venv/local/lib/python2.7/site-packages/gcloud/client.py", line 143, in __init__
    raise EnvironmentError('Project was not passed and could not be '
EnvironmentError: Project was not passed and could not be determined from the environment.

I do appear to have valid credentials. gcloud.credentials.get_credentials() happily provides me with a perfectly good GoogleCredentials object which works fine with httplib2 if I invoke it directly.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

12reactions
tseavercommented, May 12, 2016

Thanks for the report! In addition to credentials, we need to know what project to use: a given set of credentials can have access to multiple projects. On GCE / GAE, we can determine the project from the host setup. On your own machine, you need to set an environment variable. E.g.:

$ export GCLOUD_PROJECT=flaky-piecrust-227

Or you can pass the project to the Client constructor:

>>> from gcloud import pubsub
>>> client = pubsub.Client('flaky-piecrust-227')

I think the “usage doc” sections should all link to a shared page explaining this requirement (similar to the Authentication page). @dhermes, @jgeewax WDYT?

0reactions
dhermescommented, May 16, 2016

Not really. oauth2client is only concerned with auth.

Read more comments on GitHub >

github_iconTop Results From Across the Web

gcloud - Google Vision API - Project not passed - Stack Overflow
I created a test project then stored my credentials locally. However, when running the application I first authenticated via "gcloud auth ...
Read more >
One or More Projects in the solution were not loaded correctly
If you want to fix this types of error then must to update your tools, I face this problem when I was not...
Read more >
Troubleshooting CI/CD - GitLab Docs
If a pipeline did not run, it's likely that all the jobs had rules or only/except that blocked them from being added to...
Read more >
Fix program errors and improve code - Visual Studio (Windows)
Rebuild your project by either pressing F7 again (to recompile only the files with errors) or Ctrl+Alt+F7 (for a clean and complete rebuild)....
Read more >
Explore test results | IntelliJ IDEA Documentation - JetBrains
Test error. This status is assigned to tests that caused an exception from the tested source code. Test failed. If at least one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found