Issue
I have two python files in the same directory, with untitled.ipynb being the main script and Data_extractor.ipynb being the module I want to extract multiple functions from.
So I tried to extract the function called BOM_data_extractor from module Data_extractor, but got the ModuleNotFoundError. I then ran import sys and printed the default paths and one of the paths was the same directory that contained both the files.
Is there a way to do this correctly? I probably am doing something wrong
Following @Arne recommendation of changing the Data_extractor to .py, I just changed the extension name and then ran it again. I got the following error, which is strange seeing that I do not have these lines in my code.
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-44-7459b354f559> in <module>
17 if module_path not in sys.path:
18 sys.path.append(module_path)
---> 19 from Data_extractor import BOM_data_extractor
~\Desktop\Sem 4\ENGN8601\PythonCode\Data_extractor.py in <module>
123 {
124 "cell_type": "code",
--> 125 "execution_count": null,
126 "metadata": {},
127 "outputs": [],
NameError: name 'null' is not defined
Solution
Ok, so @Arne's comment of changing the filetype to .py instead of ipynb worked,.. I initially tried to just manually change the file extension, but that resulted in some null errors. Then I realised I had to go through Jupyter>File>Download as> Python file(.py) once this .py file was downloaded, I was able to call it without any issue.
Answered By - cmk101010
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.