86
80

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Anacondaを入れたらHomebrewの環境が吹っ飛んだ話

Last updated at Posted at 2016-01-20

pythonの環境をAnacondaで構築したら、homebrewで作った環境に不具合が出ました。
入れる前にいろいろ調べたのに知らなかったことなので、轍として残しておきます。

環境

MacOS X Yosemite
homebrew, Anaconda ←混ぜるな危険

もともと、homebrewを用いてNode.js等の環境を構築し、hubotと戯れていた環境。
最近、話題のTensorFlowを使ってみるべくPythonの環境をAnacondaで作り、チュートリアルを少々動かし始めていました。

久々にnpmコマンドを打ったところ…

-bash: npm: command not found

ファッ!?

助けて!brew doctor!

困ったときのbrew doctor。警告が出ています。

Warning: Anaconda is known to frequently break Homebrew builds, including Vim and
MacVim, due to bundling many duplicates of system and Homebrew-available
tools.

If you encounter a build failure please temporarily remove Anaconda
from your $PATH and attempt the build again prior to reporting the
failure to us. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
    /Users/spiky00/anaconda/bin/curl-config
    /Users/spiky00/anaconda/bin/freetype-config
    /Users/spiky00/anaconda/bin/libdynd-config
    /Users/spiky00/anaconda/bin/libpng-config
    /Users/spiky00/anaconda/bin/libpng16-config
    /Users/spiky00/anaconda/bin/python-config
    /Users/spiky00/anaconda/bin/python2-config
    /Users/spiky00/anaconda/bin/python2.7-config
    /Users/spiky00/anaconda/bin/xml2-config
    /Users/spiky00/anaconda/bin/xslt-config

どうやらAnacondaはHomebrewと同じ名前のconfigを使用するため、ビルドを壊してしまうようです。えっ

解決しました!

環境変数からAnacondaを消し、もともと設定していた$PATHを設定し直します。

vi ~/.bash_profile
# added by Anaconda2 2.4.1 installer
export PATH="/Users/spiky00/anaconda/bin:$PATH"

蛇発見。そして私のNode環境はいずこへ…

これを…

# added by Anaconda2 2.4.1 installer
# export PATH="/Users/spiky00/anaconda/bin:$PATH"

こうして…

export PATH=$HOME/.nodebrew/current/bin:$PATH
# added by Anaconda2 2.4.1 installer
# export PATH="/Users/spiky00/anaconda/bin:$PATH"

こうじゃ!

すっきり解決。まだ試してはいませんが、PATHを変更すればAnaconda環境も依然使えるはず。
環境が壊れたときはどうしようかと思いましたが、存外カンタンでよかったです!
そういえばAnaconda入れるとき何か警告があった気がする…あれはもしかして…?

86
80
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
86
80

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?