I have Fico Xpress solver installed in my mac. I can run my optimization model from command line. Before doing so, I run . /Applications/FICO\ Xpress/xpressmp/bin/xpvars.sh which runs a number of commands such as CLASSPATH=${XPRESSDIR}/lib/xprs.jar:${CLASSPATH}, export CLASSPATH etc. 
The issue is when I want to run the model in Pycharm. Pycharm doesn't seem to be able to find Xpress. The the 'optimizer' executable of Xpress cannot be found. In fact, I cannot even import xpress. 
As a potential solution, I would like to be able to launch the xpvar.sh script before I run Pycharm. 
I have been trying to use External Tool option in Pycharm, but get the error message Source this script by running 'source /Applications/fico/xpressmp/bin/xpvars.sh'
Here are the parameters I set in my External Tool:
Program: /Applications/fico/xpressmp/bin/xpvars.sh
Arguments: source
Working Directory: /Applications/fico/xpressmp/bin/ 
Any other potential solutions are also very welcome. Thanks in advance.
The problem seems to be that PyCharm is a GUI application and does not read the .bash_profile or .bashrc files where most environment variables are set. What worked for me is using the EnvFile plugin for PyCharm (I'm using the Community Edition 2019.2):

Under Preferences->Plugin, search for EnvFile;
Install the plugin, then restart PyCharm;
Create a .env file (e.g. myvars.env) containing all variables you need, one per line, in the format VARNAME=VALUE
Load your project, then under Run->Edit configurations, select the EnvFile tab;
Click on the "+" to add your myvars.env;
Maybe restart PyCharm again.

At this point your variables should be available to your Python application.
Launch a bash script before running my optimization model in Pycharm