英文:
Change environment variable setted in jupyter Notebook with magics
问题
Sure, here's the translated content:
希望这个问题还没有得到答复,我已经搜索了很多帖子,但没有一个说如何更改环境变量。
我想要加载.env
中的环境变量,所以按照这个帖子中的步骤进行操作。
%env "OPENAI_API_KEY"=OPENAI_API_KEY
然后,我想要查看我的变量:
%env OPENAI_API_KEY
一切都运行良好,但我的错误是错误地复制了我的环境变量的值。所以我想要更改它。
我尝试使用dotenv再次加载这个变量,但似乎不起作用。
希望你能帮助我,谢谢。
英文:
Hope this question is not already answered, I've searched many posts but none of them says how to change an environment variable.
I wanted to load environment variables in .env
so followed the steps in this post.
%env "OPENAI_API_KEY"=OPENAI_API_KEY
Then I wanted to see my variable with:
%env OPENAI_API_KEY
Everything worked well but my mistake was to erroneously copy the value for my environment variable. So I want to change it.
I tried dotenv to load this variable again but seems not to work.
Hope you can help me, please.
I tried doing again the same procedure so that it can be changed/updated.
答案1
得分: 0
如果你写错了API密钥:
创建一个包含你的凭据的.env
文件:
OPENAI_API_KEY="...错误的api密钥..."
你验证过了:
%env OPENAI_API_KEY
然后你意识到这是错误的。
你可以:
import os
del os.environ["OPENAI_API_KEY"]
然后:
os.environ["OPENAI_API_KEY"]="...正确的密钥..."
要验证这一点:
%env OPENAI_API_KEY
然后会提示更新后的API密钥。
英文:
If you made a mistake writing your APIKEY:
Created a .env
with your credentials:
OPENAI_API_KEY="...erroneous-api-key..."
You verified:
%env OPENAI_API_KEY
And you realized it is wrong.
You can:
import os
del os.environ["OPENAI_API_KEY"]
Then:
os.environ["OPENAI_API_KEY"]="...right-key..."
To verify this:
%env OPENAI_API_KEY
And the updated api-key should be prompted.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论