I have created an python_util.py in the same folder where I have my Jupyter Notebook. Now on Jupyter notebook I want to import that as a module.
from python_util import createLogging
createLogging is a function inside python_util.py
I get the following error -
No module named python_util Traceback (most recent call last): ImportError: No module named python_util
Can someone help me fix it ? Thanks.
-
Can you show us structure of your project files?Jjj– Jjj2019年11月11日 05:41:45 +00:00Commented Nov 11, 2019 at 5:41
-
There is same problem with solution. This will help you to understand. visit reference: [stackoverflow.com/questions/17976158/…Muhammad Usman Bashir– Muhammad Usman Bashir2019年11月11日 06:02:43 +00:00Commented Nov 11, 2019 at 6:02
1 Answer 1
You have added the local path to the path list.
import os
import sys
module_path = os.path.abspath(os.path.join('.'))
if module_path not in sys.path:
sys.path.append(module_path)
answered Nov 11, 2019 at 5:51
Bill Chen
1,73914 silver badges24 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
lang-py