简体   繁体   中英

Load environment variable from script in PyCharm

I have a script which executes python unit tests. What this script does is firstly prepare the PYTHONPATH variable and then executes the python unit tests.

I now want to run my python tests in PyCharm, however I want to reuse the script which builds the environment variables. Is there a way to specify a script to prepare the env variables in run/debug configuration in PyCharm?

You can use env-vars-in-path-vars plugin for IntelliJ IDEA family:

An IntelliJ IDEA plugin to automatically add environment variables to Path Variables.

For example, you can have a file myproject.env with next content:

SOME_VAR=SOME_VALUE

You can use this file from both your script and IDE, using the plugin and changing your environment variables would be reflected in both.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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