Python Forum
ModuleNotFoundError: No module named 'xxxx'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ModuleNotFoundError: No module named 'xxxx'
#1
I am new to Python and programming itself. I have got my working directory in ""'C:\\Users\\dell\\Desktop\\Python Practice'"". I have got a file "Python Basics.ipynb" in which I am working and it is saved in working directory. Now I have created a module with name Calc.ipynb in same working directory and this Calc has few functions which I want to call from "Python Basics.ipynb". But I am getting an error. Coding details below:

*******Calc.ipynb********************
def sum(a,b):
    return a+b
def sub (a,b):
    return a-b
def mul (a,b):
    return a*b
def div (a,b):
    return a/b
****************************
******"Python Basics.ipynb"**********************
###first I tried below code
import Calc
a = 9
b = 7
c = Calc.sum(a,b)
print (c)
Error/Response from system on execution:
ModuleNotFoundError
Error:
Traceback (most recent call last) <ipython-input-91-7f3fd0194649> in <module> 1 ## Modules - very importnat -- can create another file for my functions-- and then these funcitons can be called in my program 2 ## here - I have created a separate module as the new file in same folder directory- it will have few of the required funcitons ----> 3 import Calc 4 a = 9 5 b = 7 ModuleNotFoundError: No module named 'Calc'
---------------------------
Then I tried following code :
from Calc import *
a = 9
b = 7
c = sum(a,b)
print (c)
error is:
---------------------------------------------------------------------------
ModuleNotFoundError
Error:
Traceback (most recent call last) <ipython-input-87-bf78db7caed4> in <module> ----> 1 from Calc import * 2 a = 9 3 b = 7 4 c = sum(a,b) 5 print (c) ModuleNotFoundError: No module named 'Calc'
**************************************
Please guide where I am going wrong..
Reply
#2
I don't normally use Jupyter notebooks, but the problem is that .ipynb files are not regular python files (.py files), so that they cannot be imported out of the box. I've found a blog post of a guy who explored 8 different ways to import a notebook into another notebook. I'm sure one of these ways will work for you.
Reply
#3
(Feb-06-2020, 11:31 AM)Gribouillis Wrote: I don't normally use Jupyter notebooks, but the problem is that .ipynb files are not regular python files (.py files), so that they cannot be imported out of the box. I've found a blog post of a guy who explored 8 different ways to import a notebook into another notebook. I'm sure one of these ways will work for you.

Thanks!.. Actually I just converted the extension to .py and all is well. Thank You!!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  no module named 'docx' when importing docx MaartenRo 1 823 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 23,576 Nov-02-2023, 08:20 AM
Last Post: South_east
  ModuleNotFoundError: No module named 'requests' Serg 18 2,493 Oct-29-2023, 11:33 PM
Last Post: Serg
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 1,410 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 1,479 Aug-07-2023, 05:32 AM
Last Post: DPaul
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 2 1,308 Jul-10-2023, 03:37 AM
Last Post: Wimpy_Wellington
  How to fix this error: ModuleNotFoundError: No module named 'notears' yaoyao22 2 1,016 Jul-09-2023, 11:24 AM
Last Post: yaoyao22
  Help with pyinstaller "No module named" korenron 9 8,835 Jun-15-2023, 12:20 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 990 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  ModuleNotFoundError: No module named 'omsdk.sdkproto' donvito7 4 1,815 Oct-20-2022, 02:56 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020