【问题标题】:An error about TypeError: expected str, bytes or os.PathLike object, not NoneType关于 TypeError 的错误:预期的 str、字节或 os.PathLike 对象,而不是 NoneType
【发布时间】:2019-08-24 17:37:38
【问题描述】:

我尝试通过运行模型来纠正英语语法。

我的开发环境是Linux + Anaconda3 + Python 3.6 + CUDA 9.0 + tensorflow1.9.0

我跑完模型后,测试出现如下问题:

Traceback (most recent call last):
  File "./generate.py", line 236, in <module>
    main(args)
  File "./generate.py", line 93, in main
    fluency_scorer = FluencyScorer(args.lang_model_path, args.lang_model_data)
  File "/home/gpower/zhangtianjiu/NLP/pytorch-human-performance-gec-master/fairseq-scripts/fluency_scorer.py", line 58, in __init__
    self.task = tasks.setup_task(self.args)
  File "/home/gpower/zhangtianjiu/NLP/pytorch-human-performance-gec-master/fairseq/fairseq/tasks/__init__.py", line 19, in setup_task
    return TASK_REGISTRY[args.task].setup_task(args)
  File "/home/gpower/zhangtianjiu/NLP/pytorch-human-performance-gec-master/fairseq/fairseq/tasks/language_modeling.py", line 90, in setup_task
    dictionary = Dictionary.load(os.path.join(args.data, 'dict.txt'))
  File "/home/gpower/anaconda3/envs/tf/lib/python3.6/posixpath.py", line 78, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

我应该如何解决这个问题?

【问题讨论】:

标签: python linux tensorflow


【解决方案1】:

查看一些代码会有所帮助,但看起来a = os.fspath(a) 中的a 变量是NoneType 类型。 a 变量应该是字符串、字节或 os.PathLike 对象,以便与 os.fspath 函数一起使用。

你可以查看os.fspath函数的Python文档:python docs

【讨论】:

    猜你喜欢
    • 2019-09-27
    • 1970-01-01
    • 2023-03-14
    • 2021-03-05
    • 2017-10-23
    • 2020-07-12
    • 2019-04-11
    • 2021-10-21
    相关资源
    最近更新 更多