允许在conda env中使用系统python吗? [英] Allow use of system python in conda env?
问题描述
是否有一种方法可以强制conda在给定的环境中使用python的系统版本(以及所有系统库)?
Is there a way to force conda to use the system version of python (along with all of the system libraries) in a given env?
我启用了conda在我的shell中,默认情况下会有点烦人,因为如果我尝试运行系统python应用程序,它将获得与期望的版本不同的python版本(* buntu上的python默认为2.7),并且通常会赢得没跑我希望conda的根环境只是重定向到系统python安装。
I have conda enabled by default in my shell, which can get a bit annoying, because if I try to run a system python app, it gets a different version of python to what it is expecting (python still defaults to 2.7 on *buntu), and often won't run. I would like the root env of conda to just be a redirect to the system python install.
推荐答案
只需删除<$ c来自〜/ miniconda3 / bin /
的$ c> python 符号链接似乎可以完成任务。
Simply removing the python
symlink from ~/miniconda3/bin/
appears to do the job.
$ which python
/home/naught101/miniconda3/bin/python
$ rm /home/naught101/miniconda3/bin/python
$ which python
/usr/bin/python
$ source activate science
discarding /home/naught101/miniconda3/bin from PATH
prepending /home/naught101/miniconda3/envs/science/bin to PATH
(science)$ which python
/home/naught101/miniconda3/envs/science/bin/python
(science)$ source deactivate
discarding /home/naught101/miniconda3/envs/science/bin from PATH
$ which python
/usr/bin/python
到目前为止,这似乎并未给我造成任何问题。不幸的是,对于〜/ miniconda / bin / python3
来说,这是行不通的,因为在切换到其他使用相同python版本的环境时,conda要求使用它。但是,这个问题最初并没有引起那么多问题。
So far, this doesn't seem to have caused me any problems. Unfortunately the same doesn't work for ~/miniconda/bin/python3
, because conda requires it when switching to other envs that use the same python version. However, that one hasn't caused as many problems in the first place.
如果此确实引起了问题,那么撤消就很容易了,只是 cd〜/ miniconda / bin /; ln -s python3 python
(或您在conda根环境中使用的python版本)。您可能需要激活/取消激活环境,才能在PATH上重新获得该版本的python。
If this does cause problems, it's easy enough to undo, just cd ~/miniconda/bin/; ln -s python3 python
(or what ever version of python you're using in your conda root env). You may need to activate/deactivate an env to get that version of python back on your PATH.
这篇关于允许在conda env中使用系统python吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!