如何在Blender中使用环境变量 [英] How to use environment variables in blender

查看:277
本文介绍了如何在Blender中使用环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在〜/.bashrc文件的这两行中添加了一个环境变量

I added a enviroment variable writing in the ~/.bashrc file this two line

var="stuff.." 
export var

在普通终端中使用python解释器,这两行代码有效

using the python interpreter in a normal terminal this two lines of code works

import os
print(os.environ['var'])

但是在Blender python控制台中,它会生成KeyError,因此在打印os.environ列表时,我可以看到没有以'var'作为键的项

but in a blender python console it generate a KeyError so printing os.environ list i can see that there isn't a item with 'var' as key

所以我认为这是unix系统中环境设置的问题.谁能帮我解释一下如何为其他进程导出环境变量?谢谢你,谢谢你的英语

So i think that is a problem with the environment settings in unix system. Can anyone help me and explain how export the environment variables for the other processes? Thanks and sorry for the english

推荐答案

启动shell时,将读取 .bachrc 文件(以及类似的代码,例如 .cshrc ).,类似地,当您启动GUI桌面时,会在启动时读取shell rc文件,然后将当时的变量作为传递给任何GUI应用程序的环境的一部分,在运行时所做的更改不会在启动时被读取一个新的应用程序.您可以找到用于不同桌面的设置环境变量的方法.

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.

将环境变量传递到Blender中的一种方法是从终端窗口启动它.打开终端时将读取rc文件,也可以在启动Blender之前手动设置环境变量.

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.

为Blender设置环境变量的另一种方法是从脚本启动它,这可能是一个称为 myblender 的脚本,可以在您的 $ PATH 中找到它,也可以如果可以在真正的搅拌机之前找到它,还可以命名为 blender .在此脚本中,您可以在启动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 "$@"

这篇关于如何在Blender中使用环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆