简体   繁体   English

如何找出根Anaconda / Miniconda环境在哪里

[英]How to find out where root Anaconda/Miniconda environment

Assume I installed Anaconda/Miniconda (with conda 4.5.*) but didn't add it to PATH. 假设我安装了Anaconda / Miniconda(含conda 4.5。*),但没有将其添加到PATH。 Then I created environment in non-standard location (not in ./envs/ ). 然后,我在非标准位置(不在./envs/ )创建环境。 Now everything I know is the path to python exec in this environment. 现在,我所知道的就是在这种环境下通往python exec的路径。 How can I activate it? 我该如何激活它? Should I find out where original root Miniconda is installed? 我应该找出原始根Miniconda的安装位置吗? How? 怎么样? Is there any way I can figure out that it's a conda created environment (so that it differs from other python)? 我有什么办法可以确定这是一个由conda创建的环境(因此它不同于其他python)?

And I need methods that solve this problem both on Windows and on Linux. 我需要在Windows和Linux上都能解决此问题的方法。 Actually I need to generate wrapper that activates conda env/virtual env (or don't activate if it's not an env) from setup.py post-install script that is pip installed from source (not wheel). 实际上,我需要从setup.py从源(不是wheel)安装的安装后脚本中生成激活conda env / virtual env(或者如果不是env则不要激活)的包装器。 I already know that if on Windows when pip is run it prepends <pyhon_env>\\Library\\bin to PATH (maybe if it's not already there), but it's not enough (or I don't know how to use it). 我已经知道,如果在Windows上运行pip时,它会将<pyhon_env>\\Library\\bin为PATH(也许尚不存在),但这还不够(或者我不知道如何使用它)。

When run Conda sets CONDA_ROOT environment variable that contains absolute path to the root of the Anaconda/Miniconda installation (even if you didn't add it to PATH). 运行时,Conda会设置CONDA_ROOT环境变量,该变量包含指向Anaconda / Miniconda安装根目录的绝对路径(即使您没有将其添加到PATH中)。

So you can get access to CONDA_ROOT when setup.py is run (during creation of env from yaml that has pip deps) and store it somewhere. 因此,当运行setup.py时(从具有pip deps的yaml创建env期间),您可以访问CONDA_ROOT并将其存储在某个位置。 I still don't know how to find conda root when installation is finished and you activate env and pip install... 我仍然不知道如何在安装完成后找到conda根目录,然后激活env和pip install ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM