python - 导入错误: No module named 'support'

标签 python module

我已经提到了与没有名为 <module name> 的模块相关的所有问题 StackOverflow 上的问题,但没能解决我的具体问题。因此,我发布这个问题。

我目前正在开发一个 python 项目,并尝试运行 run_bsg.py文件来自this project 。但是,我不断收到以下错误。

错误

Traceback (most recent call last):
  File "/home/nayantara/PycharmProjects/BSG/run_bsg.py", line 3, in <module>
    from interfaces.interface_configurator import InterfaceConfigurator
  File "/home/nayantara/PycharmProjects/BSG/interfaces/interface_configurator.py", line 1, in <module>
    from libraries.data_iterators.open_text_data_iterator import OpenTextDataIterator
  File "/home/nayantara/PycharmProjects/BSG/libraries/data_iterators/open_text_data_iterator.py", line 2, in <module>
    from support import deal_with_accents
ImportError: No module named 'support'

Python代码

# this file contains an example on how to run the bayesian skip-gram model
import os
from interfaces.interface_configurator import InterfaceConfigurator
from libraries.evaluation.support import evaluate
from libraries.evaluation.lexsub.run_lexsub import run_lexsub

train_data_path = 'data/datafile.txt' 
vocab_file_path = 'vocabulary/2M.txt' 
output_folder_path = "output/2M/"  

# obtain the interface to interact with the model.
i_model = InterfaceConfigurator.get_interface(train_data_path, vocab_file_path, output_folder_path)

i_model.train_workflow()

# store the temporary vocab, because it can be different from the original one(e.g. smaller number of words)
vocab = i_model.vocab
temp_vocab_file_path = os.path.join(i_model.output_path, "vocab.txt")
vocab.write(temp_vocab_file_path)

mu_vecs = [os.path.join(i_model.output_path, "mu.vectors")]
sigma_vecs = [os.path.join(i_model.output_path, "sigma.vectors")]

# a complex of word embedding evaluations(word similarity, entailment, directional entailment)
evaluate(mu_vectors_files=mu_vecs, sigma_vectors_files=sigma_vecs, vocab_file=temp_vocab_file_path, log_sigmas=False,
         full_sim=True, vocab=vocab)

# run additionally lexical substitution evaluation
run_lexsub(input_folder=i_model.output_path, output_path=i_model.output_path)

open_text_data_iterator.py

from nltk import word_tokenize as default_tokenizer
from support import deal_with_accents
from libraries.utils.paths_and_files import get_file_paths

...

任何这方面的建议将不胜感激

最佳答案

我按照 @ClockSlave 的建议重新发布了这个问题的答案。根据以下错误行,

File "/home/nayantara/PycharmProjects/BSG/libraries/data_iterators/open_text_data_iterator.py", line 2, in <module>
from support import deal_with_accents
ImportError: No module named 'support'

open_text_data_iterator.py文件中的第2nd行import语句需要修改如下。

from libraries.data_iterators.support import deal_with_accents

这解决了我的问题。

关于python - 导入错误: No module named 'support' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56268585/

相关文章:

python - Psycopg2 显示错误

python - 如何使用 python 查找二元组的对数概率?

python - 导入 Python 类

javascript - 如何使用 ECMA 模块在 nodejs 中导入 .json 文件?

module - 如何重新导出枚举?

Python 在覆盖率和 Nose 下运行时看不到子模块

python - 如何在 python 中删除给定开始和结束标记的子字符串?

python - pandas 与 numpy 的不同标准

Python 找不到 Importlib

facebook - 在 Node.js 中获取 Facebook 页面的公共(public)提要