Using VS Code for Python programming with Jupyter Notebook

Using VS Code for Python programming on Windows OS.

Installed VS Code, Installed Python extensions by Microsoft.

Installed Jupyter extension.

Created a blank notebook and wrote python script.

The first line where I wrote “from helper_functions import get_llm_response” gives an error.

ModuleNotFoundError: No module named ‘helper_functions’

What’s wrong? Anyone using the same set up to code? Can you please provide step by step instructions or we can also connect via google meet if required. I’m in EST time zone.

Thanks in advance,

Shreyas

1 Like

Dear @shreyasDLAI,

Welcome to the Community!

Have you downloaded all the labfiles?

Looking forward to learning and growing together.


Keep Learning AI with DeepLearning.AI - Girijesh

You need the helper_functions.py file.

1 Like

Hi Shreyas,

The error ModuleNotFoundError: No module named 'helper_functions' means that Python can’t find a file or package called helper_functions.py in your current environment or working directory. A few things to check step by step:

  1. Check if the file exists

    • Make sure you actually have a file named helper_functions.py in the same folder as your Jupyter notebook.

    • If it’s in another folder, you’ll need to either move it next to your notebook or adjust the Python path (sys.path) or use a relative import.

  2. Kernel and environment

    • Sometimes VS Code runs a Jupyter kernel from a different Python environment than the one you expect.

    • In the top right of your notebook, check the kernel selected. It should match the environment where your code and libraries live.

  3. Restart and re-run

    • After adding the file, restart the Jupyter kernel (in VS Code: Kernel > Restart Kernel) and then re-run all cells.

Example: if your project folder looks like this:

project/
  ├── helper_functions.py
  ├── notebook.ipynb

Then from helper_functions import get_llm_response will work.

If helper_functions.py is inside a subfolder (say utils/), you’d import like this:

from utils.helper_functions import get_llm_response

So the fix is usually just making sure your .py file is in the right place and that your notebook is running in the correct environment.

Let me know if you want me to walk through setting this up in VS Code step by step.

—Steve

Thank you @SteveArthur

I downloaded helper_functions.py file and placed it in the root folder from where I run the scripts.

This led to another error that says “ModuleNotFoundError: No module named ‘openai’“

How do I get openAi module?

Please try with pip install openai command.

Thanks a lot @SteveArthur

I had to install openai in my virtual environment and after that I also had to install pandas to the virtual environment.

Also, had to download the latest helper_functions.py file from module 3 last lesson that included display_table function.

Doing all above, resolved the issues I was facing.

Again, many thanks.

Shreyas

Hi Shreyas,

Glad to hear it worked out and that the solution helped! Thanks for marking it as the answer.

I’m always happy to support and also open to exploring new roles and surprising opportunities in the AI/ML space. If you ever come across something interesting or want to collaborate, feel free to reach out.

Best,
Steve