簡體   English   中英

無法使用 Jupyter 筆記本在 Python 中導入自定義模塊

[英]Not able to import custom modules in Python using Jupyter notebook

我在 Jupyter Notebook 所在的同一文件夾中創建了一個 python_util.py。 現在在 Jupyter 筆記本上,我想將其作為模塊導入。

from python_util import createLogging

createLogging 是 python_util.py 中的 function

我收到以下錯誤 -

沒有名為 python_util 的模塊 Traceback(最近一次調用最后一次):ImportError: No module named python_util

有人可以幫我解決嗎? 謝謝。

您已將本地路徑添加到路徑列表中。

import os
import sys
module_path = os.path.abspath(os.path.join('.'))
if module_path not in sys.path:
    sys.path.append(module_path)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM