简体   繁体   English

如何在不设置shell路径的情况下将Anaconda与系统python隔离开来

[英]How to isolate Anaconda from system python without set the shell path

I want to install Anaconda locally on my home directory ~/.Anaconda3 (Archlinux) and without setting the path in the shell because I like to keep my system python as the default. 我想在我的主目录〜/ .Anaconda3(Archlinux)本地安装Anaconda,而不在shell中设置路径,因为我喜欢将我的系统python作为默认值。

So I like to launch the Spyder (or other Anaconda's app) as isolated app from system binaries. 所以我喜欢将Spyder(或其他Anaconda的应用程序)作为系统二进制文件中的独立应用程序启动。 I mean when I launch for example .Anaconda3/bin/spyder it launches spyder and this app uses Anaconda's binaries but when I use python ThisScript.py in my shell it uses system python installed from packages (eg /bin/python). 我的意思是当我发布例如.Anaconda3/bin/spyder它启动spyder并且这个应用程序使用Anaconda的二进制文件但是当我在我的shell中使用python ThisScript.py时它使用从包安装的系统python(例如/ bin / python)。

I managed to update the anaconda using .Anaconda3/bin/conda update --all in my shell without setting the Anaconda's binaries path ( .Anaconda/bin/ ) but thsi way run some apps like spyder doesn't work obviously. 我设法使用.Anaconda3/bin/conda update --all update更新anaconda - 在我的shell中没有设置Anaconda的二进制路径( .Anaconda/bin/ ),但是运行一些像spyder这样的应用程序显然不起作用。

You could use virtualenv 你可以使用virtualenv

1) create a virtual env using the python version you need for anaconda virtualenv -p /usr/bin/pythonX.X ~/my_virtual_env 1)使用anaconda virtualenv -p /usr/bin/pythonX.X ~/my_virtual_env所需的python版本创建虚拟virtualenv -p /usr/bin/pythonX.X ~/my_virtual_env

2) virtualenv ~/my_virtual_env/bin/activate 2) virtualenv ~/my_virtual_env/bin/activate

3) Run anaconda, then deactivate 3)运行anaconda,然后deactivate

Currently this zsh function solves the problem using temporarily change the shell path variable. 目前, 这个 zsh函数使用临时更改shell路径变量来解决问题。 I just need to: 我只需要:

1) anaconda_on 1)anaconda_on

2) which python or python --version or spyder .... 2) which pythonpython --versionspyder ....

3) anaconda_off 3)anaconda_off

This is neat and solves my problem. 这很整洁,解决了我的问题。 But there might be more universal way for this. 但可能有更普遍的方式。 Any suggestion? 有什么建议吗? There are many cases which is better to isolate anaconda from the system python. 有很多情况下最好将anaconda与系统python隔离开来。

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

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