0

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.

asked Nov 11, 2019 at 5:41
2
  • Can you show us structure of your project files? Commented Nov 11, 2019 at 5:41
  • There is same problem with solution. This will help you to understand. visit reference: [stackoverflow.com/questions/17976158/… Commented Nov 11, 2019 at 6:02

1 Answer 1

0

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.