简体   繁体   English

在python任务之前从shell脚本加载环境变量 Pycharm 2018.1专业版

[英]Load Environment Variables from shell script before python task | Pycharm 2018.1 PRO

I'm trying to run a python task within run/debug configuration task option. 我正在尝试在运行/调试配置任务选项中运行python任务。

My problem is that I need to load some environment variables from a bash script. 我的问题是我需要从bash脚本加载一些环境变量。

In my normal terminal is as simple as <source file.sh> and then I can execute my script without any problem. 在我的普通终端中,就像<source file.sh>一样简单,然后我可以执行脚本了而没有任何问题。

I already tried doing a external tool (to execute the sh file) an put on "before launch" option inside run/debug configuration 我已经尝试过使用外部工具(以执行sh文件)在运行/调试配置中放置“启动前”选项

but did not work. 但没有用。

Any ideas/help? 有任何想法/帮助吗?

You could set the environment variables before starting PyCharm. 您可以在启动PyCharm之前设置环境变量。 This way, they should propagate to processes launched by PyCharm, and you c an re-use the existing bash script. 这样,它们应该传播到由PyCharm启动的进程,并且您可以重新使用现有的bash脚本。

But if you can put the environment variable settings into a file of the appropriate format, the EnvFile suggestion in this answer appears to be a good solution. 但是,如果您可以将环境变量设置放入适当格式的文件中,则此答案中的EnvFile建议似乎是一个很好的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM