Id : CommandNotFoundException
🚨 错误信息
export : 无法将“export”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写
,如果包括路径,请确保路径正确,然后再试一次。
所在位置 行:1 字符: 1
+ export OPENAI_API_KEY="https://api.chatkore.com"
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (export:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
🤖 AI解决方案
export : The term 'export' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ export OPENAI_API_KEY="https://api.chatkore.com"
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (export:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
原因分析
在 Windows PowerShell 中,export 不是一个内置命令。你可能是在 Linux/macOS 环境中使用 export 命令来设置环境变量,但在 PowerShell 中,设置环境变量的语法是不同的。
解决方案
在 PowerShell 中,使用 $env: 前缀来设置环境变量。
$env:OPENAI_API_KEY = "https://api.chatkore.com"
预防措施
- 区分Shell环境: 在执行命令前,确认你当前使用的Shell环境(如 Bash, Zsh, PowerShell, Cmd 等),并使用该Shell对应的语法。
- 查阅官方文档: 对于不确定的命令或语法,查阅相关技术(如 PowerShell, API文档)的官方文档是获取准确信息的最佳途径。