問題描述
如果這在其他地方很容易找到,我們深表歉意,但盡管我找到了一些帶有 pyenv 和 Anaconda 解釋的帖子,但沒有一個專門解決這個問題.但是,我經常是個白癡.
Sincerest apologies if this is easily found elsewhere, but although I found a number of posts with pyenv and Anaconda explanations, none addressed this issue specifically. However, I am often an idiot.
在 Mac OSX (Mojave 10.14.6) 上,我通過 Homebrew 安裝了 pyenv
On Mac OSX (Mojave 10.14.6) I installed pyenv via Homebrew
brew install pyenv
我很樂意安裝并在 Python 版本之間切換
And I happily install and switch between Python versions with
pyenv 安裝 ...
和
pyenv 全局 ...
我通常使用 VS Code 作為我的 IDE.
I typically use VS Code as my IDE.
我現在需要在 Anaconda 中做一些工作.我以前沒用過.我可以簡單地安裝 Anaconda 通過分發站點 并使用它的導航器,當我需要舊的 python 版本時使用pyenv和VS Code,還是安裝Anaconda的時候會沖突?如果會發生沖突,是否有在 OSX 上同時運行兩者的路徑?
I now have need to do some work in Anaconda. I haven't used it before. Can I simply install Anaconda via the distribution site and use its navigator, and when I need my old python versions use pyenv and VS Code, or will there be a conflict when I install Anaconda? If there would be a conflict, is there a path to running both on OSX?
我當然可以安裝它,看看會發生什么,如果它很亂,可以從備份中恢復.但我希望 pyenv/Anaconda 大師可能會提出一些明智的建議,這可能會節省我數小時的清理時間.
I could install it and see what happens of course, and restore from backup if it's a big mess. But I'm hoping that a pyenv / Anaconda guru might have some sage words of advice that would save me potentially hours of cleaning up.
提前致謝!
推薦答案
有沖突,導致 pyenv
和 conda
都嘗試默認暴露全局 Python 環境.
There is a conflict, cause both pyenv
and conda
try to expose a global Python environment by default.
我一直在使用這些工具,我找到的最佳解決方案是
I've been using these tools together and best solution found by me is to
- 始終初始化
pyenv
,使用pyenv global
設置的Python作為默認Python - 僅公開命令
conda
但不激活任何環境
- Alway initialize
pyenv
, use the Python set bypyenv global
as the default Python - Only expose command
conda
but do NOT activate any environment from it
詳情
由于你的機器上已經安裝了pyenv
,你只需要安裝Anaconda即可.
Detail
Since pyenv
has been installed on your machine, you only need to install Anaconda.
brew cask install anaconda
初始化 conda
而不暴露 conda
的基礎"環境.
Init conda
without exposing the "base" environment from conda
.
# init conda, the following command write scripts into your shell init file automatically
conda init
# disable init of env "base"
conda config --set auto_activate_base false
完成.
注意:在此設置之后,默認的 Python 是 pyenv global
設置的那個.使用 pyenv
和 conda
分別管理環境.
Note: After this setup, the default Python is the one set by pyenv global
. Use pyenv
and conda
to manage environments separately.
管理虛擬環境的示例.
# virtual environments from pyenv
pyenv install 3.6.9
pyenv virtualenv 3.6.9 new-env
pyenv activate new-env
pyenv deactive
# You can also use `pyenv local`
# virtual environments from conda
conda create -n new-env python=3.6
conda env list
conda activate new-env
conda deactivate
pyenv
的默認環境位置是 ~/.pyenv/versions
.
Default env location for pyenv
is ~/.pyenv/versions
.
conda
的默認環境位置,檢查 conda info
的輸出.
Default env location for conda
, check output from conda info
.
- conda 入門李>
- 在 Conda 環境中使用 Pip,非常重要
- 如何防止 Conda 默認激活基礎環境?
這篇關于除了 OSX 上現有的 pyenv 安裝之外,如何安裝 Anaconda?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!