I am trying to use Bloomberg python API. I need to set BLPAPI_ROOT environment variable for this. I added,
export BLPAPI_ROOT="/home/user/Downloads/blpapi_cpp_3.6.3.1"
export PATH=$PATH:$BLPAPI_ROOT
to my .bashrc file and ran source .bashrc. Now, when I open python shell and do,
print os.environ['BLPAPI_ROOT']
it gives me correct output. But when the same this runs inside the setup.py provided, it throws a
Traceback (most recent call last):
File "setup.py", line 27, in <module>
blpapiRoot = os.environ['BLPAPI_ROOT']
File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__
raise KeyError(key)
KeyError: 'BLPAPI_ROOT'
What am I missing here ?
System : Ubuntu 12.04 Python 2.7
I would try using it the following way:
import os
try:
os.environ['BLPAPI_ROOT'] = "/home/user/Downloads/blpapi_cpp_3.6.3.1"
except EnvironmentError:
sys.exit(1)
This is quite old, but for anyone searching, you can get around this by setting sudo to keep the environmental variable BLPAPI_ROOT, a la keep environmental variables using sudo .
sudo visudo
Then add:
Defaults env_keep +="BLPAPI_ROOT"
You can now run:
sudo python setup.py install
and it should work just fine.
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.