python - VS Code 代码运行器扩展:由于空格而努力将 Python PATH 添加到 settings.json
问题描述
我正在尝试让 Code Runner 在我的 Windows 计算机上处理 VS 代码(尽管我使用 WSL 的大部分工作都涉及 Python)。我已经使用 Anaconda 安装了 Python
C:\\Users\\FirstName LastName\\anaconda3\\python.exe
您可能会注意到文件路径中的空格。
我已将其添加到我的settings.json
...
{
"terminal.integrated.inheritEnv": false,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"python.dataScience.sendSelectionToInteractiveWindow": true,
"code-runner.executorMap": {
"python": "C:\\Users\\FirstName LastName\\anaconda3\\python.exe",
},
"python.autoComplete.extraPaths": [
]
}
...但是当我使用 Code Runner 运行 Python 脚本时,我不断收到此错误:
[Running] C:\Users\FirstName LastName\anaconda3\python.exe "c:\Users\FirstName LastName\Documents\PythonFolder\pythonscript.py"
'C:\Users\FirstName' is not recognized as an internal or external command,
operable program or batch file.
看起来它对那里的空白不满意。我检查了另一个问题中提出的解决方案,该解决方案要添加"python": "python"
到settings.json
,但这只是给了我这个:
'python' is not recognized as an internal or external command,
operable program or batch file.
知道如何进行这项工作吗?
解决方案
编辑您的代码运行器 setting.json 并添加此设置:
1.来自这个Qiita帖子
{
"code-runner.executorMap": {
"python": "python -u",
},
}
或者 2.来自这个 StackOverFlow 帖子
{
"code-runner.executorMap": {
"python":"$pythonPath $fullFileName",
},
}
或者 3.来自这个 NewBeDev 帖子
{
"code-runner.executorMap": {
"python": "$pythonPath -u $fullFileName",
},
}
只需尝试其中之一!
推荐阅读
- node.js - 是否可以导入符号链接文件并让导入的文件导入从符号链接位置而不是原始位置解析
- sql - SQL:返回日期最早的记录
- maps - 为什么 Here Maps Routes App 和 Web 不同
- jquery - 使用动态创建的内容清除 Div 的问题
- laravel-5.7 - 如何在laravel数据库的一列中插入多个字段数据
- java - 如何删除 XYLineAndShapeRenderer 中的点?
- python - 从 s3 存储桶下载所有文件,包括分页 python
- python - 如何在 Matplotlib 中连接图形坐标?
- excel - 从 excel 文件提供的数据中自定义异常
- javascript - 如何将模块导出的函数导入 HTML onclick="" 事件处理程序的全局范围?