"Can't find 'utils' module" in very first step of course

I am trying to run this locally - I have obtained an API key, and set it in an environment variable.

When I start this course, I am not able to get past the very first cell…

from utils import get_api_key

Running this results in an error. I have confirmed that I DID install the proper components using the command: “pip install -q google.generativeai” (I ran it twice, and confirmed it was installed correctly)…I also restarted Jupyter notebooks after setting this up.

Any ideas why this error is happening?:

ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 1
----> 1 from utils import get_api_key

ModuleNotFoundError: No module named ‘utils’

I’ve also been searching for a different Python package with this method, and I am not able to find a relevant package to install.

Hi @boogermike

Welcome to the community.

The utils package is a custom package.

Some packages might be attached in the course platform.

If you trying to running on your own environment, you have to download all the files related to the course in order to get it work.

For example:

You might be able to access all the stored files by clicking on the jupyter logo at the top-left.

This example above is from another course. Just take as a reference

I hope this help

Best regards


Hi @elirod , I am having the same issue. Unfortunately, I couldn’t not find where the course resources are.


Hi @Eugen79

Welcome to the community.

Please, follow the instructions above. Keep in mind that these instructions are regards the course assets. If you try to run locally, you have to download and install all the packages that are from python envirioment.

For example, if the course uses a external package, you have to install it on your envirioment by your own.

Best regards


Being able to see what is in the utils python package, I just copied it directly, and this worked.

Specifically these steps:.

  1. get rid of that first cell
  2. In the second (now first cell) use this:
import os
import google.generativeai as palm
from google.api_core import client_options as client_options_lib
from dotenv import load_dotenv, find_dotenv

_ = load_dotenv(find_dotenv()) # read local .env file
apiKey = os.getenv('GOOGLE_API_KEY')


Also, this flow assumes you have an environment variable set with the name GOOGLE_API_KEY that contains your API key for Palm API (you will need that)

This DID help so much. I was able to find the package using the method you described, and confirmed the code in there.

Appreciate your response which was helpful and accurate.

1 Like

It was my pleasure. Don’t forgot to mark the answer as a solution in order to move it to the top of this post and help other learners.

I copy your solution but still got an error:

----> 4 from dotenv import load_dotenv, find_dotenv
6 _ = load_dotenv(find_dotenv()) # read local .env file
7 apiKey = os.getenv(‘GOOGLE_API_KEY’)

ModuleNotFoundError: No module named ‘dotenv’

What was I missing? an env variable? How should I set it?

Thank you very much!

Hi a complete beginner this side can you please explain what you did here

Thanks for your cooperation

Hi @hungbhuynh

Welcome to the community.

You have to install the dotenv package if you are running your code locally

Thank you! It work for me

Open your terminal or command prompt and run the following command:

pip install python-dotenv

Collecting python-dotenv
Downloading python_dotenv-1.0.0-py3-none-any.whl (19 kB)
Installing collected packages: python-dotenv
Successfully installed python-dotenv-1.0.0

1 Like

Well done, @hungbhuynh

I’m glad to help

I am trying to run locally.
I got into trouble when running following cell:

for m in palm.list_models():
print(f"name: {m.name}“)
print(f"description: {m.description}”)
print(f"generation methods:{m.supported_generation_methods}\n")

Error: DefaultCredentialsError: Your default credentials were not found.

Question: How do to set up Application Default Credentials?