久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Anaconda 和 Brew 的最佳實踐

Best Practices with Anaconda and Brew(Anaconda 和 Brew 的最佳實踐)
本文介紹了Anaconda 和 Brew 的最佳實踐的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我剛買了一臺裝有 OSX Sierra 的新 Macbook,所以想確保我的開發環境設置正確.

我希望遵循此處提到的最佳實踐":https://github.com/nicolashery/mac-dev-setup

我需要 Python 2.x 來工作(urllib、Pandas、Numpy、Scikit-learn),而 Python 3.x 需要我正在學習的一些在線課程(Pandas、Numpy、Django).我已經分別使用 brew install pythonbrew install python3 安裝了 Python 2 和 3.

但是,在這個鏈接上,沒有提到 Anaconda,只有 IPython.鑒于我已經通過 Homebrew 安裝了 Python 2 和 3,是否建議使用 anaconda,或者我應該堅持使用上面 Github 鏈接中提到的標準 IPython?讀完這篇文章后我很困惑:OS X - 在 anaconda 之間決定和自制 Python 環境

如果 Brew 和 Anaconda 確實可以一起工作,我可以采取哪些具體步驟來確保兩個版本之間沒有沖突?

解決方案

brewconda 往往不能很好地結合在一起,但我想我有一個設置到目前為止對我來說效果很好.它的靈感來自這篇文章.p>

您可以將以下代碼添加到您的.zshrc:

# 在運行 brew 之前停用 conda.# 如果 conda 在完成時處于活動狀態,則重新激活它.釀造(){本地 conda_env=$CONDA_DEFAULT_ENV"而[$CONDA_SHLVL"-gt 0];做康達停用完畢命令沖泡$@本地 brew_status=$?[ -n ${conda_env:+x}"] &&conda 激活$conda_env"返回$brew_status"}

您想在運行 brew 之前停用 conda 以便 brew 在您的PATH 每當它嘗試安裝某些東西時.事實上,如果您在運行 brew 之前沒有停用 condabrew doctor 會報錯,正如我在上面鏈接到的帖子中提到的那樣.(另請參閱這個問題.)

我應該提到的一件事是 conda 環境堆棧",但是我上面編寫的 brew() 函數不會跟蹤您的堆棧環境.(有關跟蹤此功能的版本,請參見下文.)例如,如果您執行 conda activate newenvconda 環境 oldenv 處于活動狀態,然后 conda deactivate 會將您返回到 oldenv.但是,如果您在激活 oldenvnewenv 后使用我上面編寫的函數運行 brew,則運行 conda deactivate 不會將您返回到 oldenv,但會完全停用您的 conda 環境.

這個函數在運行 brew 時也可能會產生一些不必要的開銷,因為我相信你只需要在運行 brew installconda 環境代碼>.也就是說,如果你是那種足夠關心開銷的人,那么這個答案可能不會告訴你任何你不知道的事情.

最后一點,brew cask install anaconda 在我看來并不是一個好主意,因為 conda 被設計為安裝在 $HOME,但 brew cask 會希望將其安裝在 /usr/local 中,這樣可能會導致不可預知的行為.

這是 brew 函數的一個版本,它使您的 conda 環境保持原樣:

brew() {本地 -a conda_envs而[$CONDA_SHLVL"-gt 0];做conda_envs=("$CONDA_DEFAULT_ENV"$conda_envs)康達停用完畢命令沖泡$@本地 brew_status=$?$conda_envs 中的環境;做conda 激活$env";完畢未設置環境返回$brew_status"}

我已經在 Zsh 中對此進行了測試.我認為它不會在 Bash 中工作.如果你想在 Bash 中使用它,你需要將 for 循環聲明更改為類似于 for env in ${conda_envs[@]} 的內容.但是,我沒有對此進行測試,因此請在使用前測試它是否能滿足您的需求.

I have just got a new Macbook with OSX Sierra, so want to ensure my development environment is setup properly.

I am looking to follow the 'best practices' mentioned here: https://github.com/nicolashery/mac-dev-setup

I need Python 2.x for work (urllib, Pandas, Numpy, Scikit-learn), and Python 3.x for some online classes (Pandas, Numpy, Django) I am taking. I have installed Python 2 and 3, using brew install python and brew install python3 respectively.

However, on this link, there is no mention of Anaconda, just IPython. Given that I already have Python 2 and 3 installed via Homebrew, is it even advisable to use anaconda, or should I stick to standard IPython as mentioned on the Github link above? I am confused after reading this post: OS X - Deciding between anaconda and homebrew Python environments

If Brew and Anaconda can indeed work together, what specific steps can I take to ensure that there are no conflicts between the two versions?

解決方案

brew and conda tend not to play nicely together, but I think I have a set up that has worked quite well for me so far. It was inspired by this post.

You can add the following code to your .zshrc:

# Deactivates conda before running brew. 
# Re-activates conda if it was active upon completion.

brew() {
    local conda_env="$CONDA_DEFAULT_ENV"
    while [ "$CONDA_SHLVL" -gt 0  ]; do
        conda deactivate
    done
    command brew $@
    local brew_status=$?
    [ -n "${conda_env:+x}" ] && conda activate "$conda_env"
    return "$brew_status"
}

You want to deactivate conda before running brew so that brew doesn't find conda packages in your PATH whenever it tries to install something. In fact, brew doctor will complain if you have not deactivated conda before running brew, as mentioned in the post I link to above. (See also this question.)

One thing I should mention is that conda environments "stack", but the brew() function I've written above does not keep track of your stack of environments. (See below for a version of this function that keeps track of this.) For example, if you do conda activate newenv while a conda environment oldenv is active, then conda deactivate will return you to oldenv. However, if you run brew using the function I've written above after activating oldenv and then newenv, running conda deactivate will not return you to oldenv but will deactivate your conda environments entirely.

This function also probably creates some unnecessary overhead when running brew, as I believe you only really need to deactivate your conda environment when running brew install. That said, if you're the kind of person to care about that overhead enough, this answer probably doesn't tell you anything you didn't already know.

As a final note, brew cask install anaconda does not strike me as a good idea, since conda was designed to be installed in $HOME, but brew cask will want to install it in /usr/local, so that could lead to unpredictable behaviour.

Edit: Here's is a version of the brew function which leaves your conda environments as it found it:

brew() {
    local -a conda_envs
    while [ "$CONDA_SHLVL" -gt 0  ]; do
        conda_envs=("$CONDA_DEFAULT_ENV" $conda_envs)
        conda deactivate
    done
    command brew $@
    local brew_status=$?
    for env in $conda_envs; do
        conda activate "$env"
    done
    unset env
    return "$brew_status"
}

I've tested this in Zsh. I don't think it will work in Bash. If you want to use it in Bash, you will need to change the for loop declaration to say something like for env in ${conda_envs[@]}. I haven't tested this, however, so please test that it does what you need before use.

這篇關于Anaconda 和 Brew 的最佳實踐的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to install Selenium in a conda environment?(如何在 conda 環境中安裝 Selenium?)
get the CUDA and CUDNN version on windows with Anaconda installe(使用 Anaconda installe 在 Windows 上獲取 CUDA 和 CUDNN 版本)
How can I download Anaconda for python 3.6(如何下載適用于 python 3.6 的 Anaconda)
Using two different Python Distributions(使用兩個不同的 Python 發行版)
How can I install Anaconda aside an existing pyenv installation on OSX?(除了 OSX 上現有的 pyenv 安裝之外,如何安裝 Anaconda?)
Permanently set Python path for Anaconda within Cygwin(在 Cygwin 中為 Anaconda 永久設置 Python 路徑)
主站蜘蛛池模板: 99re| 欧美性生活免费 | 久久久综合久久 | 国产高清在线视频 | 欧美成人a | 久久国产成人午夜av影院武则天 | 9999国产精品欧美久久久久久 | 成人免费视频网站在线看 | 先锋资源站 | www.黄网| 欧美日韩三级在线观看 | 国产亚洲日本精品 | 日韩成人免费视频 | 精品九九九 | 999久久久久久久久6666 | 亚洲一区二区三区高清 | 国产乱码久久久久久 | www.午夜 | 国产成人艳妇aa视频在线 | 美女人人操 | 亚洲精品久久久一区二区三区 | 日韩精彩视频 | sese视频在线观看 | 秋霞电影院午夜伦 | 久久精品视频在线免费观看 | 欧美日韩久久精品 | 羞羞视频在线观看 | 欧美日韩在线精品 | 91亚洲一区 | 羞羞视频在线观看 | 午夜电影网址 | 每日更新av| 久久毛片| 精品国产色 | 亚洲97| 精品中文在线 | 国产一级片免费在线观看 | 欧美一级在线观看 | 我想看国产一级毛片 | 一区二区在线不卡 | 亚洲综合大片69999 |