【发布时间】:2021-10-03 10:22:26
【问题描述】:
我的代码结构如下:
Graph API/
│── main.py
├── helper_functions/
├── defines.py
├── insights.py
insights.py开头从defines.py导入2个函数:
from defines import getCreds, makeApiCall
然后它为此函数使用“makeApiCall”:
def getUserMedia( params ) :
// Some code about url endpoints etc.
return makeApiCall( url, endpointParams, params['debug'] ) # make the api call
我想在 main.py 脚本中使用 getUserMedia 函数,所以我将其导入:
from helper_functions.insights import *
但我得到了错误:
Traceback (most recent call last):
File "/Users/Graph_API/main.py", line 1, in <module>
import helper_functions.insights
File "/Users/Graph_API/helper_functions/insights.py", line 1, in <module>
from defines import getCreds, makeApiCall
ModuleNotFoundError: No module named 'defines'
是什么导致了这个错误?当我在insights.py 中使用getUserMedia 函数时,它工作正常。我也已经尝试将 define.py 导入 main.py,但我得到了同样的错误。
我是编程新手,非常感谢您的帮助 :)
【问题讨论】:
标签: python function recursion import python-import