How To Use Environment Variables In Blender
Solution 1:
The .bachrc
file (and similar such as .cshrc
) is read when your shell is started, similarly when you start a GUI desktop the shell rc files are read at the time of it starting and the variables at that time are then part of the environment passed onto any GUI apps, changes made while running do not get read in as you start a new app. You can find ways of setting environment variables for different desktops.
One way of passing environment variables into blender is to start it from a terminal window. The rc files will be read when you open the terminal, you can also manually set environment variables before starting blender.
Another way to set environment variables for blender is to start it from a script, this may be one called myblender
that will be found in your $PATH
or it can also be named blender
if it will be found before the real blender. In this script you can set variables before starting blender and any changes will be in effect when you run it.
#!/bin/bash
var="stuff.."export var
exec /usr/local/bin/blender "$@"
Solution 2:
After updating ~/.bashrc you either have to source ~/.bashrc
in the terminal where you launch blender
or log out and log back in to your system, where the variable should then be in the environment.
If you need to get environment variables that may or may not be available, you can also do something like os.getenv('var', 'default value')
Post a Comment for "How To Use Environment Variables In Blender"