【问题标题】:module not found Error: Cannot resolve module 'opensubtitles'找不到模块错误:无法解析模块“opensubtitles”
【发布时间】:2022-01-04 11:16:18
【问题描述】:

我已尽一切努力解决此问题。 我是python的初学者。我的文件夹结构:

├─conversational-datasets-master-opensubtitles/ 
└── conversational-datasets-master/ 
└── opensubtitles/
  └── create_data.py
  └── create_data_test.py
  • 在 opensubtitles 文件夹中,我有两个文件
  • 第一个是用于火车的 create_data.py
  • 第二个是create_data_test.py,用于测试

所以问题是 每当我尝试运行 create_data_test.py 时,它都会显示此错误(找不到模块错误)

File "C:\Users\suppo\Desktop\conversational-datasets-master-opensubtitles\conversational-datasets-master\opensubtitles\create_data_test.py", line 15, in <module>
    import opensubtiles.create_data.py
ModuleNotFoundError: No module named 'opensubtiles'

【问题讨论】:

    标签: python testing dataset


    【解决方案1】:

    尝试更改create_data_test.py 中的导入语句 来自:

    import opensubtitles.create_data.py
    

    到:

    import create_data
    

    【讨论】:

      【解决方案2】:

      我想你只是在这里打错了......

      导入 opensubti t les.create_data.py

      有几篇关于在python中导入模块和类的帖子。看看这里...希望对您有所帮助

      How to import the class within the same directory or sub directory?

      【讨论】:

      【解决方案3】:
      from opensubtitles import create_data
      from opensubtitles import create_data_test
      

      这应该可以。 但如果您在根文件夹中,则可能必须使用 joinpath,因为文件夹名称中有连字符。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-06-29
        • 2016-12-10
        • 2018-01-20
        • 2021-11-24
        • 2017-05-22
        • 2016-10-27
        • 2017-03-22
        相关资源
        最近更新 更多