这个问题与Spacy项目有关
如何重现行为
在project.yml
的脚本部分添加一个非Python命令。例如,在下面的代码片段中,我包含了一个mkdir
命令。
- name: "train"
help: "Train a named entity recognition model"
script:
- "mkdir C:/test_folder"
- "python -m spacy train ${vars.config} --output ./output --paths.train assets/${vars.train}.spacy --paths.dev assets/${vars.dev}.spacy"
deps:
- "assets/${vars.train}.spacy"
- "assets/${vars.dev}.spacy"
outputs:
- "output/model-best"
包含此命令后,我得到以下错误:
=================================== train ===================================
Running command: mkdir C:/test_folder
Traceback (most recent call last):
File "C:\Users\10347298\.conda\envs\nlpenv\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\10347298\.conda\envs\nlpenv\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\10347298\.conda\envs\nlpenv\lib\site-packages\spacy\__main__.py", line 4, in <module>
setup_cli()
File "C:\Users\10347298\.conda\envs\nlpenv\lib\site-packages\spacy\cli\_util.py", line 71, in setup_cli
command(prog_name=COMMAND)
File "C:\Users\10347298\.conda\envs\nlpenv\lib\site-packages\click\core.py", line 1137, in __call__
return self.main(*args, **kwargs)
File "C:\Users\10347298\.conda\envs\nlpenv\lib\site-packages\click\core.py", line 1062, in main
rv = self.invoke(ctx)
File "C:\Users\10347298\.conda\envs\nlpenv\lib\site-packages\click\core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\10347298\.conda\envs\nlpenv\lib\site-packages\click\core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\10347298\.conda\envs\nlpenv\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\10347298\.conda\envs\nlpenv\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "C:\Users\10347298\.conda\envs\nlpenv\lib\site-packages\typer\main.py", line 500, in wrapper
return callback(**use_params) # type: ignore
File "C:\Users\10347298\.conda\envs\nlpenv\lib\site-packages\spacy\cli\project\run.py", line 42, in project_run_cli
project_run(project_dir, subcommand, overrides=overrides, force=force, dry=dry)
File "C:\Users\10347298\.conda\envs\nlpenv\lib\site-packages\spacy\cli\project\run.py", line 100, in project_run
run_commands(cmd["script"], dry=dry, capture=capture)
File "C:\Users\10347298\.conda\envs\nlpenv\lib\site-packages\spacy\cli\project\run.py", line 183, in run_commands
run_command(command, capture=capture)
File "C:\Users\10347298\.conda\envs\nlpenv\lib\site-packages\spacy\util.py", line 955, in run_command
raise FileNotFoundError(
FileNotFoundError: [E970] Can not execute command 'mkdir C:/test_folder'. Do you have 'mkdir' installed?
spaCy信息
- spaCy版本: 3.2.4
- 平台: Windows-10-10.0.19042-SP0
- Python版本: 3.8.11
- Pipelines: en_core_web_sm (3.1.0)
2条答案
按热度按时间ugmeyewa1#
提议的解决方案
在进一步分析这个问题时,我发现,如果我在这条命令中的
subprocess.run()
后面添加一个选项shell=True
,那么错误就不会抛出。有人能验证一下吗?uz75evzq2#
感谢您提出这个问题并发布了一个解决方法!我们会研究一下(
shell=True
可能还有其他影响,我们需要先评估一下)。