Anaconda Python:虚拟环境存储在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35709497/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Anaconda Python: where are the virtual environments stored?
提问by StillLearningToCode
I am new to Anaconda Python and I am setting up a project in Sublime Text 3. I have installed Anaconda and created a virtual environment using:
我是 Anaconda Python 的新手,我正在 Sublime Text 3 中设置一个项目。我已经安装了 Anaconda 并使用以下方法创建了一个虚拟环境:
conda create -n python27 python=2.7 anaconda
conda create -n python35 python=3.5 anaconda
I am having trouble setting up the Virtualenvs plugin for SublimeText 3.
我在为 SublimeText 3 设置 Virtualenvs 插件时遇到问题。
When I try, it asks me for a virtualenvs path which I give:
当我尝试时,它会询问我提供的 virtualenvs 路径:
~/users/../anaconda/envs/python27
Then it asks for what I'm assuming is a path to a python distribution because it lists file paths for the system versions of python -- but not the anaconda install.
然后它会询问我假设是 python 发行版的路径,因为它列出了 python 系统版本的文件路径——但不是 anaconda 安装。
I have no real desire to use the plug in, I just want to be able to use both versions of python. Could I use a project settings file to set the version of python instead?
我没有真正想要使用插件的愿望,我只想能够使用两个版本的python。我可以使用项目设置文件来设置python的版本吗?
回答by Josh
If you activate the environment you're interested in, you can find that answer in the environment variables.
如果您激活您感兴趣的环境,您可以在环境变量中找到答案。
on MacOS/Linux:
在 MacOS/Linux 上:
source activate python35
echo $CONDA_PREFIX
on Windows:
在 Windows 上:
conda activate python35
echo %CONDA_PREFIX%
You can also run conda info --envs
, and that will show the paths to all your environments.
您也可以运行conda info --envs
,这将显示所有环境的路径。
To get the path to the instance of python being used by a particular environment, do the following:
要获取特定环境正在使用的 python 实例的路径,请执行以下操作:
on MacOS/Linux:
在 MacOS/Linux 上:
source activate python35
which python
on Windows:
在 Windows 上:
conda activate python35
where python
That should return the path you're looking for.
那应该返回您正在寻找的路径。
回答by Jason Angel
Your environments are located in Anaconda3\envs\<yourEnv_directory>\
您的环境位于 Anaconda3\envs\<yourEnv_directory>\
回答by Geo Angelopoulos
You can run the command conda info
.
您可以运行该命令conda info
。
This will output something like this:
这将输出如下内容:
envs directories : C:\Users\Geo\.local\Miniconda3\envs
C:\Users\Geo\.conda\envs
C:\Users\Geo\AppData\Local\conda\conda\envs
I have installed conda at C:\Users\Geo\.local\Miniconda3.
我已经在 C:\Users\Geo\.local\Miniconda3 安装了 conda。
Then with the command conda info -e
you get the location of each environment.
然后使用该命令conda info -e
可以获得每个环境的位置。
(base) C:\Users\Geo>conda info -e
# conda environments:
#
miniconda2 C:\Users\Geo\.conda\envs\miniconda2
base * C:\Users\Geo\.local\Miniconda3
anaconda3 C:\Users\Geo\.local\Miniconda3\envs\anaconda3
ml C:\Users\Geo\.local\Miniconda3\envs\ml
回答by Kevin S
None of the other windows solutions worked for me so I'm providing my own. Activate the environment inside anaconda prompt, then issue the command 'where python' and you'll likely see multiple results but one of them, most likely the top one, is the one you're after. For me, my environments were located in AppData\Local... which is not what anyone else had mentioned but the best solution is to use 'where python' which should result in an answer regardless of how you've installed Anaconda.
其他 Windows 解决方案都不适合我,所以我提供了自己的解决方案。激活 anaconda 提示符内的环境,然后发出命令“where python”,您可能会看到多个结果,但其中之一,很可能是最上面的一个,就是您想要的结果。对我来说,我的环境位于 AppData\Local... 这不是其他人提到的,但最好的解决方案是使用“where python”,无论您如何安装 Anaconda,这都应该得到答案。
回答by MSeifert
To answer your question the folder for your python binaries and packages for the environment are located in ~Anaconda_installation_folder~/envs/python35
.
要回答您的问题,您的 python 二进制文件和环境包的文件夹位于~Anaconda_installation_folder~/envs/python35
.
But I cannot really say if that solves your problem. Normally you just switch to your environment source activate python35
and then type python
. This will automatically give you the "right" python executable. So if you have a package you could use:
但我真的不能说这是否能解决你的问题。通常,您只需切换到您的环境source activate python35
,然后键入python
. 这将自动为您提供“正确的”python 可执行文件。所以如果你有一个包,你可以使用:
source activate python35
python setup.py install
# Now it is installed in your python35 environment
source activate python27
python setup.py install
# Now it is also installed in your python27 environment
Just change python setup.py install
to what you want to do in the environment. I don't have any experience using Sublime Text and what you mean with build system
. But you can always use something like tox
which automates a lot of these manual builds.
只需更改python setup.py install
为您想要在环境中执行的操作即可。我没有任何使用 Sublime Text 的经验以及您对build system
. 但是你总是可以使用类似的东西tox
来自动化很多这些手动构建。
回答by seulberg1
For me, with default anaconda settings and Windows 10, the path that displays after activating the environment is C:\Users\usrname>
, but it does not contain an Anaconda3 folder. However, it contains a .conda
folder that contains an environments.txt
file that lists all conda environments and their locations. By default, the environment folders were stored in:
对我来说,使用默认的anaconda设置和Windows 10,激活环境后显示的路径是C:\Users\usrname>
,但它不包含Anaconda3文件夹。但是,它包含一个.conda
文件夹,其中包含一个environments.txt
列出所有 conda 环境及其位置的文件。默认情况下,环境文件夹存储在:
C:\Users\usrname\AppData\Local\conda\conda\envs\EnvName
回答by jturi
None of the above worked. In the end, I found mine at:
以上都没有奏效。最后,我在以下位置找到了我的:
c:\Users\myusername\venvs\test1-V7fphpR9\
c:\Users\myusername\venvs\test1-V7fphpR9\
回答by suman95
- Open your c directory
- Go to Users and then Open your naming folder (in my case Suman Biswas)
- Fiend Anaconda3 folder
- Fiend the folder envs in Anaconda3
- Now you can see your virtual environment
- 打开你的c目录
- 转到用户,然后打开您的命名文件夹(在我的情况下是 Suman Biswas)
- Fiend Anaconda3文件夹
- 在 Anaconda3 中找到文件夹 envs
- 现在您可以看到您的虚拟环境
回答by Contango
On Windows 10 x64 and Anaconda3, the python interpreter for a newly created environment "my_env" would appear here:
在 Windows 10 x64 和 Anaconda3 上,新创建的环境“my_env”的 python 解释器将出现在这里:
C:\ProgramData\Anaconda3\envs\my_env\python.exe