Jupyter - can't import utils

In Jupyter I have tried this:

Import our class, and instantiate

import os
import sys
module_path="‪C:/Users/Windows/Desktop/"
import Vgg16

and get back the following:
ImportError Traceback (most recent call last)
in ()
3 import sys
4 module_path=“‪C:/Users/Windows/Desktop/”
----> 5 import Vgg16

ImportError: No module named Vgg16

I’ve tried “import Vgg16.py” but same problem. I can’t seem to get this working . . .

I realise this may not be worthy of this group’s consideration (I’m pretty amazed at the coding qualifications in the room and I just don’t stack up).

Thanks!

Do you need to add “module_path” into your system environment variable list?

Hi!

I am using this:

Import our class, and instantiate

import os
import sys
module_path="‪C:/Users/Windows/Desktop/"
import Vgg16

So module_path is in there. . .

Or is the system environment variable something else? How do I access it?

Thanks heaps!

-Warren

You need to place the .py files in the same place that you run ‘jupyter notebook’ from.

1 Like

Thanks heaps!

You guys are amazing. . .

-Warren

@jeremy, where do I find the .py files? I am having the same issue as @warren did.

----> 5 import Vgg16

ImportError: No module named Vgg16

I am running the .ipynb file on my local Ubuntu 16.4 computer since there is a GPU on it. So I think I do not have anything pre-loaded. Thank you!

You’ll need to do the github setup shown in the setup video.

Hi @jeremy, thanks. I am working on the AWS set-up shown in the video. However I am stuck at the step of bacsh setup_t2.sh. I downloaded this .sh file from this GitHub page since the www.platform.ai/files/ page is not working anymore.

The error meassge is like this:

setup_t2.sh: line 7: syntax error near unexpected token newline' setup_t2.sh: line 7:'`

Below is the screen shot that shows the error I got - I tried to chmod of the .sh but it still does not work. Your help are highly appreciated!

1 Like

Very common problem - please search the forum.

Hi there, I’ve searched a while for this exact error, but can’t find anything like it.

I ssh into my p2 instance fine, but on importing the utils and vvg16 python files I get the following error:

File “utils.py”, line 7

^
SyntaxError: invalid syntax

It seems to be in the actual syntax.

in the terminal in the folder where nbs are I write the following to get both the files:

wget https://github.com/fastai/courses/blob/master/deeplearning1/nbs/utils.py
wget https://github.com/fastai/courses/blob/master/deeplearning1/nbs/vgg16.py

Then I open up Jupyter Notebooks and go into Lesson1ipynb and all works fine. But when i get to importing the utils and vgg16, I get the same error above.

Any help much appreciated!!

@matthewmat - Can you pls show some screenshots of the code, and also the folder structure? I assume you have all the files - utils.py, vgg16.py in the same folder as lesson1.ipynb file.

I managed to fix this problem

The ‘wget’ was importing the files in html format. To fix, I created a blank utils.py file, and then copied and pasted the code from the git repository. After this it worked

1 Like

Hello, i just copy the url from raw file in the github
wget https://raw.githubusercontent.com/fastai/courses/master/deeplearning1/nbs/utils.py