【问题标题】:Cannot run my code for a chatbot application无法为聊天机器人应用程序运行我的代码
【发布时间】:2018-07-30 09:59:03
【问题描述】:

收到此错误 我的输入文件是

def get_data_from_file(file_path=os.path.('C:/Users/anees/chatbot_data.txt')):
    with open(file_path) as infile:
        cleaned_lines = [line.strip() for line in infile if not line.startswith(('$$$', '###', '==='))]

    return cleaned_lines

错误

C:\Users\anees\Anaconda3\envs\chatbot\python.exe C:/Users/anees/PycharmProjects/Web_analytics/Assignment1/knowlege_extraction.py
Traceback (most recent call last):
  File "C:/Users/anees/PycharmProjects/Web_analytics/Assignment1/knowlege_extraction.py", line 245, in <module>
    main()
  File "C:/Users/anees/PycharmProjects/Web_analytics/Assignment1/knowlege_extraction.py", line 218, in main
    triples = cl.extract_triples(sents)
  File "C:\Users\anees\Anaconda3\envs\chatbot\lib\site-packages\pyclausie-0.1-py2.7.egg\pyclausie\SubprocessBackend.py", line 62, in extract_triples
    stderr=subprocess.PIPE)
  File "C:\Users\anees\Anaconda3\envs\chatbot\lib\subprocess.py", line 390, in __init__
    errread, errwrite)
  File "C:\Users\anees\Anaconda3\envs\chatbot\lib\subprocess.py", line 640, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

Process finished with exit code 1

【问题讨论】:

  • 找不到错误请帮忙
  • os.path. 中的第二个点是故意的吗?
  • 不,这不是故意的......也没有必要使用 os.path

标签: python python-2.7 pycharm anaconda


【解决方案1】:

试试

os.path.join("Users","anees","chatbot_data.txt")

建立路径。

【讨论】:

    【解决方案2】:

    如果您提供完整路径,则无需使用 os.path.join() 只需使用 file_path 如下所示:

    file_path=r'C:/Users/anees/chatbot_data.txt'

    或者你可以使用os.path.join(),如下:

    os.path.join("Users","anees","chatbot_data.txt")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-31
      • 2020-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-27
      • 1970-01-01
      相关资源
      最近更新 更多