0

I have a helper_functions.py file that I want to use some functions from, but nothing seems to work.

from helper_functions import plot_decision_boundary

ImportError: cannot import name 'plot_decision_boundary' from 'helper_functions' (/content/helper_functions.py)

from helper_functions import *

runs, but when I call any function I get

name 'plot_decision_boundary' is not defined

I tried the solutions to the two most similar questions this and this, but nothing seems to work.

I am working on collab and have manually uploaded the file.

!ls lists the file

Iliasp
  • 143
  • 8

1 Answers1

0

Then I leave you some examples of different ways to import a module.

Your file:

  # module.py
      def fun1(n):
          return n+1

1-> import:

import module
module.fun1(1000) #1001

2-> from:

from module import fun1
fun1(1000) #1001

3-> import *:

from module import *
fun1(1000) #1001

4-> import as:

import module as lib
lib.fun1(1000) #1001

Make sure that the file you want to import is in the same folder, if it is not in the same folder, indicate the name in the "import" if the folder is in the same root.

from .MyFolder import module

References: https://docs.python.org/2/tutorial/modules.html https://en.wikibooks.org/wiki/A_Beginner%27s_Python_Tutorial/Importing_Modules