[英]Setting environment to use PyOpenColorIO in a Jupyter Notebook
In my notebook I would like to use PyOpenColorIO.在我的笔记本中,我想使用 PyOpenColorIO。 I have installed that library via brew install opencolorio
and I have confirmed that I can use it from within my pipenv
-created virtual environment (both from the REPL as well as from a script) after source
-ing the environment configuration that ships with the library.我已经安装了通过图书馆brew install opencolorio
和我已经证实,我可以从我的内使用pipenv
后-created虚拟环境(无论是从REPL以及从脚本) source
-ing的环境配置附带的库.
However, I am unable to set up this environment from within my notebook and thus cannot use the library from there - import PyOpenColorIO as OCIO
always throws No module named 'PyOpenColorIO'
.但是,我无法从笔记本中设置此环境,因此无法从那里使用库 - import PyOpenColorIO as OCIO
总是抛出No module named 'PyOpenColorIO'
。
Things I've tried so far and their results:到目前为止我尝试过的事情及其结果:
export
ed from the shell file with %env
or %setenv
before importing OCIO, both using quotes and without quotes在导入 OCIO 之前,使用%env
或%setenv
设置从 shell 文件export
每个变量,使用引号和不使用引号
%env
, but ${PATH}
and Co are not substituted使用%env
检查时设置变量,但未替换${PATH}
和 Coos.environ["VARNAME"]
before importing OCIO在导入 OCIO 之前使用os.environ["VARNAME"]
设置每个变量
!source /usr/local/share/ocio/setup_ocio.sh
at the beginning of the notebook在笔记本的开头运行!source /usr/local/share/ocio/setup_ocio.sh
%env
at all %env
根本没有变化It seems to me that there should be a way of setting up the environment as part of the kernel startup, before any cells are executed.在我看来,在执行任何单元之前,应该有一种方法将环境设置为内核启动的一部分。 However I haven't been able to find such an option.但是,我一直无法找到这样的选项。 Does it exist?它存在吗? Or is there any other way to get OCIO to work in a notebook using a virtual environment?或者有没有其他方法可以让 OCIO 在使用虚拟环境的笔记本中工作?
After digging around some more, I found a solution that works: pipenv can automatically load .env files .在进一步挖掘之后,我找到了一个有效的解决方案: pipenv 可以自动加载 .env 文件。
This sets the variables before they are needed to load the module.这会在需要加载模块之前设置变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.