python - 导入错误:无法导入名称 'x'

标签 python importerror

有很多这样的话题,但我仍然很困惑。我收到导入错误,但我不知道我做错了什么......

错误消息如下:

  File "/app/src/pptxbuilder/app.py", line 85, in <module>
    __web_setup()
  File "/app/src/pptxbuilder/app.py", line 35, in __web_setup
    from pptxbuilder.views.home import home_bp
  File "/app/src/pptxbuilder/views/__init__.py", line 2, in <module>
    from .builder import builder_bp
  File "/app/src/pptxbuilder/views/builder.py", line 30, in <module>
    from pptxbuilder.app import app
  File "/app/src/pptxbuilder/app.py", line 85, in <module>
    __web_setup()
  File "/app/src/pptxbuilder/app.py", line 36, in __web_setup
    from pptxbuilder.views.builder import builder_bp
ImportError: cannot import name 'builder_bp'

这是我的路径:

src\pptxbuilder\app.py
src\pptxbuilder\views\builder.py
src\pptxbuilder\views\home.py

在“builder.py”中我有这个变量

builder_bp = Blueprint('builder', __name__)

在“home.py”中我有这个变量

home_bp = Blueprint('home', __name__)

我正在“app.py”中运行下面的行

'from pptxbuilder.views.builder import builder_bp' 

最佳答案

删除 pptxbuilder。

from views.builder import builder_bp

简单的例子,但概念应该是相同的。当然,您的确切代码会有所不同。 enter image description here

关于python - 导入错误:无法导入名称 'x',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50547819/

相关文章:

python - 如何在 python 中开始和结束读取特定字符串的文件?

python - 检查特定字符是否在字符串中

python - 如何对连续峰宽进行聚类

python - 从项目列表创建特定形状的 Pandas 数据框

python - 在 Python 和 IronPython 之间传递 pickle

python - 为什么在函数中使用模块后重新导入会抛出异常?

python - 过滤数据透视表列中的值

python - importError : no module named pysphere

python virtualenv ImportError 没有名为 inspect time flask 的模块

python - '导入错误: DLL load failed' when fetching MNIST original via sklearn