ModuleNotFoundError: No module named 'xxxx' - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: ModuleNotFoundError: No module named 'xxxx' (/thread-24258.html) |
ModuleNotFoundError: No module named 'xxxx' - darpInd - Feb-06-2020 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 ---------------------------Then I tried following code : from Calc import * a = 9 b = 7 c = sum(a,b) print (c)error is: --------------------------------------------------------------------------- ModuleNotFoundError **************************************Please guide where I am going wrong.. RE: ModuleNotFoundError: No module named 'xxxx' - Gribouillis - Feb-06-2020 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. RE: ModuleNotFoundError: No module named 'xxxx' - darpInd - Feb-06-2020 (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!! |