程序看不到 Conda 定义的环境变量
Conda defined environment variable not seen by program
我有一个具有以下结构的 python 项目:
在conda.yml
中我定义了一些环境变量如下:
name: terraform_module_overview
dependencies:
- pip
- pip:
- stashy
- oauthlib
- requests_oauthlib
variables:
- BB_USER=someUser
而在python程序python/terraformModuleMarkdownGenerator.py
中,我尝试读取环境变量如下:
import os
print(os.getenv("BB_USER")
然后当我尝试使用 conda 环境执行它时,在项目的根目录下使用这些命令:
conda env create --file conda.yml && \
conda run -n terraform_module_overview python/terraformModuleMarkdownGenerator.py
安装成功依赖项:
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done
Installing pip dependencies: ...working... done
...但执行失败:
ERROR conda.cli.main_run:execute(33): Subprocess for 'conda run
['python/terraformModuleMarkdownGenerator.py']' command failed. (See
above for error)
None
ERROR: BB_USER is undefined in the Environment
我在这里缺少什么?
看起来像是定义变量的语法不正确 (see documentation)。相反,尝试
conda.yml
name: terraform_module_overview
dependencies:
- pip
- pip:
- stashy
- oauthlib
- requests_oauthlib
variables:
BB_USER: someUser
我有一个具有以下结构的 python 项目:
在conda.yml
中我定义了一些环境变量如下:
name: terraform_module_overview
dependencies:
- pip
- pip:
- stashy
- oauthlib
- requests_oauthlib
variables:
- BB_USER=someUser
而在python程序python/terraformModuleMarkdownGenerator.py
中,我尝试读取环境变量如下:
import os
print(os.getenv("BB_USER")
然后当我尝试使用 conda 环境执行它时,在项目的根目录下使用这些命令:
conda env create --file conda.yml && \
conda run -n terraform_module_overview python/terraformModuleMarkdownGenerator.py
安装成功依赖项:
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done
Installing pip dependencies: ...working... done
...但执行失败:
ERROR conda.cli.main_run:execute(33): Subprocess for 'conda run ['python/terraformModuleMarkdownGenerator.py']' command failed. (See above for error)
None
ERROR: BB_USER is undefined in the Environment
我在这里缺少什么?
看起来像是定义变量的语法不正确 (see documentation)。相反,尝试
conda.yml
name: terraform_module_overview
dependencies:
- pip
- pip:
- stashy
- oauthlib
- requests_oauthlib
variables:
BB_USER: someUser