No module named 'dlai_tools' in pycharm

Hi guys,

I know I am not good with py yet. When I do homework, I always test my code in pycharm.
I am in the class " Improving Deep Neural Networks: Hyperparameter Tuning, Regularization and…", and very first hw “Initialization”. In the website browser (Jupter), the first block works fine, with no problem at all. However, if I copy the first block to pycharm, error says “No module named 'dlai_tools”. I do downloaded init_utils.py, public_tests.py.

Can anyone give me a hint on how to fix this?

Btw, Week 3 No module named 'dlai_tools' - #10 by Kinzang_Dorji shows I need to change the first 2 lines in public_tests.py to

“import numpy as np
from test_utils import single_test, multiple_test”

Then I have “No module named ‘test_utils’”. I do found this “test_utils” from “Hw3_Deep Neural Network - Application”, Now, I have no error after coping test_utils to current homework folder. But I am not sure I will have problem later on or not. Can someone advise me ?

@ paulinpaloalto

Hi Paul, could you please take a look if possible? thank you!!!

Hey @sunson29,
You don’t need to copy all the files individually to your local machine. You can easily download all the files associated with a particular assignment at once, instructions here. Once you have downloaded all the files and made the changes mentioned in the thread that you referred to, I don’t think that you should face any more errors, but if you do, feel free to let us know, and we will help you out.

Cheers,
Elemento

but the problem is, in this file “public_tests.py”, there is no “dlai_tools”. I think this is not the problem of downloading, am I right?

Hey @sunson29,

Aren’t the above changes solving the issue?

Cheers,
Elemento

you are right, same thing here. Please check the picture below. I do use the “download all”. Like I said, the code need “dlai_tools” , but there is no “dlai_tools” file. Again, this is not working for my pycharm, but I am not sure how comes this works in Jupyter from the browser.
image
image
image

Yes, please change the second line of code to the below line of code:

from test_utils import single_test, multiple_test

And let me know if this helps.

Cheers,
Elemento

no working, please check the pictures below

image
image
image

there is no test_utils.py file. In the folder, there are only 3 files.
Btw, I do found this “test_utils” from “Hw3_Deep Neural Network - Application”, If I copy that file to here, it will work. But I am not sure I am just lucky here and will have issues in the future or not.

And here, you need to download all the files, as I stated before. When you will download all the files, you will find a file by the name of test_utils.py. Place it in your folder, and it will work afterwards. If it still doesn’t work, let me know and I will see to it tomorrow. Right now, dinner-time :yum:

Cheers,
Elemento

oh, no problem. thank you!
I am confused now when you said to download everything. Please check the folder below. In this W1A1, there are only 2 lib py files, and I copied all to my local drive. Is this correct? I am very new in py, maybe I am missing something.
image

Btw, in other folders, W1A2, W1A3, there is no test_utils.py.

That’s indeed strange. Apologies, looks like the Coursera labs are not synced correctly. I have attached the test_utils.py file here, for your reference. You can download and use it. I hope this helps.

test_utils.py (5.9 KB)

Cheers,
Elemento

thank you! Your dinner is done?

May I ask, this is a silly question. How comes this works in the browser(Jupter) without “test_utils.py” or “dlai_tools” ? It seems like Jupter gets library files from other places ?

Hey @sunson29,
Yes, my dinner is done, thanks for asking.

And this is not a silly question at all, in fact, it’s quite a valid question. By the way, it’s not something that is happening due to the use of Jupyter notebooks, but due to how the Coursera labs are working. It seems like the Coursera labs are using some files which they haven’t made available for download.

Please allow me to tag @Mubsi here, as he will be knowing more about this. Hey Mubsi, can you please let us know why the test_utils.py file is unavailable for download in DLS C2 W1 A2? Thanks in advance.

Cheers,
Elemento

oh, thank you. Let’s see what will happen later.

Hi @sunson29, @Elemento,

Yes, from the looks of it, the the testing utility is being used from elsewhere, from our internal tools, which is why it is not publicly available.

With that being said, you don’t need to look at that file, it must have been made hidden for a reason, because the learners are not supposed play around with it. And it only contains code to verify the outputs.

Best,
Mubsi

thank you!!!

Hey @Mubsi,
I agree with your view-point, but don’t you think, it will create an issue for learners who are trying to download the files and run the assignment locally just like @sunson29 faced it here? I am not sure but if the test_utils.py file contains the solution or something like that, can you please add a note regarding this in the assignment, something along the lines:

“Attention learners! You won’t be able to download this assignment and run locally on your machine due to some files being hosted on private server.”

Cheers,
Elemento

1 Like

Hi @Elemento,

The purpose of putting up the assignments on Coursera is that the learners don’t have to do anything extra in order to run them and to get the grade. And you are aware, that we don’t necessarily provide support in running the assignments locally, so they are not designed that way.

Alternatively, if someone wants to run them locally, they still can do it by eliminating the unit test related code, as its mere purpose is to evaluate the implementation of the learners.

Cheers,
Mubsi

Hey @Mubsi,

Indeed this is something that helps the learners to cross the barrier to start coding by a great extent, since they don’t have to spend their time in installing packages, setting up environment, etc.

I will make sure to convey this to any learner who faces a similar issue in the future. Thanks a lot, once again :nerd_face:

Cheers,
Elemento

2 Likes

thanks, guys. But dont forget about the original question :slight_smile:
The problem was not this test_utils, it was “dlai_tools”. Hence, the hidden file is “dlai_tools”, I guess, not the “test_utils”