kuroの覚え書き

96の個人的覚え書き

Anacondaに手を出す

ずっとPythonは素のPython3をつかっている。
Anacondaはいっとき手を出した事はあるが、conda以外のpipでインストールしたライブラリとの折り合いが悪く、結局アンインストールして今に至る。
しかし素のPython3では依存関係がうまく構築できない案件がやはり出てくるので、pyenvで共存を図ることにしたい。

homebrewでpyenvとpyenv-virtualenvをインストールする。
そのために

$ brew update
Updated 4 taps (qmk/qmk, homebrew/core, homebrew/cask and brewsci/bio).
==> New Formulae
・・・・・
You have 132 outdated formulae and 2 outdated casks installed.
You can upgrade them with brew upgrade
or list them with brew outdated.

$ brew upgrade
==> Upgrading 132 outdated packages:
・・・・・
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /usr/local/Cellar/openssl@1.1/1.1.1k... (8,071 files, 18.5MB)
Error: Permission denied @ apply2files - /usr/local/lib/docker/cli-plugins

久しぶりにMacのHomebrewをアップデートしたら(もしかしたらCatarinaにアップデートして初めて?)いきなりエラーでつまづく。

$ sudo chown -R $(whoami) $(brew --prefix)/*

$ brew upgrade
==> Upgrading 130 outdated packages:
・・・・・
Warning: Your Xcode (11.3.1) is outdated.
Please update to Xcode 12.4 (or delete it).
Xcode can be updated from the App Store.
・・・・・
==> Caveats
`osxfuse` has been succeeded by `macfuse` as of version 4.0.0.

To update to a newer version, do:
  brew uninstall osxfuse
  brew install macfuse

osxfuse requires a kernel extension to work.
If the installation fails, retry after you enable it in:
  System Preferences → Security & Privacy → General

For more information, refer to vendor documentation or this Apple Technical Note:
  https://developer.apple.com/library/content/technotes/tn2459/_index.html

You must reboot for the installation of osxfuse to take effect.
・・・・・
Error: emacs: It seems the App source '/Applications/Emacs.app' is not there.

なにやら不穏なCaveatsやWarningがたびたび出て、あげくまた別のエラーで止まる。
Emacsなんてそもそも入れてないはずなんだけどなあ。

$ brew reinstall emacs --cask --no-quarantine
==> Downloading https://emacsformacosx.com/emacs-builds/Emacs-28.1-4-universal.d
Already downloaded: /Users/kuro/Library/Caches/Homebrew/downloads/96cf5c42fb25db0b78be33651afe4cd8fc82097a0a81e10b4125a5d2831a125d--Emacs-28.1-4-universal.dmg
==> Uninstalling Cask emacs
==> Purging files for version 25.2 of Cask emacs
==> Installing Cask emacs
Warning: macOS's Gatekeeper has been disabled for this Cask
==> Moving App 'Emacs.app' to '/Applications/Emacs.app'
==> Linking Binary 'Emacs' to '/usr/local/bin/emacs'
==> Linking Binary 'ebrowse' to '/usr/local/bin/ebrowse'
==> Linking Binary 'emacsclient' to '/usr/local/bin/emacsclient'
==> Linking Binary 'etags' to '/usr/local/bin/etags'
==> Linking Manpage 'ebrowse.1.gz' to '/usr/local/share/man/man1/ebrowse.1.gz'
==> Linking Manpage 'emacs.1.gz' to '/usr/local/share/man/man1/emacs.1.gz'
==> Linking Manpage 'emacsclient.1.gz' to '/usr/local/share/man/man1/emacsclient
==> Linking Manpage 'etags.1.gz' to '/usr/local/share/man/man1/etags.1.gz'
🍺  emacs was successfully installed!

$ brew upgrade
Running `brew update --preinstall`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> New Casks
bili-downloader
==> Updated Casks
Updated 2 casks.

なんかわからんがようやくbrew upgradeまで完了。

$ brew install pyenv pyenv-virtualenv

$ nano .bashrc
# pyenv
PYENV_ROOT=~/.pyenv
export PATH=$PYENV_ROOT/bin:$PATH
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

# brew doctor
alias brew="env PATH=${PATH/\/Users\/${USER}\/\.pyenv\/shims:/} brew"

を.bashrcに追記

$ source .bashrc

$ pyenv install anaconda3-5.3.1
Downloading Anaconda3-5.3.1-MacOSX-x86_64.sh.sh...
-> https://repo.continuum.io/archive/Anaconda3-5.3.1-MacOSX-x86_64.sh
Installing Anaconda3-5.3.1-MacOSX-x86_64.sh...
Installed Anaconda3-5.3.1-MacOSX-x86_64.sh to /Users/kkuro/.pyenv/versions/anaconda3-5.3.1

$ pyenv virtualenv anaconda3-5.3.1 anac1
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.5.11
  latest version: 4.12.0

Please update conda by running

    $ conda update -n base -c defaults conda
・・・・・
# To activate this environment, use:
# > source activate anac1
#
# To deactivate an active environment, use:
# > source deactivate
#

Looking in links: /var/folders/sf/3lk5x37135586w0jgqyjq_yc0000gn/T/tmpwy8czazq
Requirement already satisfied: setuptools in /Users/kuro/.pyenv/versions/anaconda3-5.3.1/envs/anac1/lib/python3.10/site-packages (61.2.0)
Requirement already satisfied: pip in /Users/kuro/.pyenv/versions/anaconda3-5.3.1/envs/anac1/lib/python3.10/site-packages (21.2.4)

$ source activate anac1
pyenv-virtualenv: activate anac1
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.

$ source deactivate
pyenv-virtualenv: deactivate anaconda3-5.3.1/envs/anac1

anac1という名前で仮想環境を作る。
ホームディレクトリにanac1というディレクトリを作り、仮想環境はその中だけで動作させる設定にしたい。

$ mkdir anac1
$ cd anac1
$ pyenv versions
* system (set by /Users/kkuro/.pyenv/version)
  anac1
  anaconda3-5.3.1
  anaconda3-5.3.1/envs/anac1
$ pyenv local anac1

ここでプロンプトが

kuro-Mac:anac1 kuro$ 

から

(anac1) kuro-Mac:anac1 kuro$ 

というように頭に(anac1)がつく。

(anac1) kuro-Mac:anac1 kuro$ pyenv versions
  system
* anac1 (set by /Users/kuro/anac1/.python-version)
  anaconda3-5.3.1
  anaconda3-5.3.1/envs/anac1

(anac1) kuro-Mac:anac1 kuro$ cd

kuro-Mac:~ kuro$ pyenv versions
* system (set by /Users/kuro/.pyenv/version)
  anac1
  anaconda3-5.3.1
  anaconda3-5.3.1/envs/anac1

このようにanac1ディレクトリから出ると素のPython3環境に自動的に戻る。

さて、Anacondaを入れることにした要因のETE Toolkitをインストールしておこう。
先ほど作成したanac1ディレクトリに入り

$ conda create -n ete3 python=3
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.5.11
  latest version: 4.12.0

Please update conda by running

    $ conda update -n base -c defaults conda
・・・・・
#
# To activate this environment, use:
# > source activate ete3
#
# To deactivate an active environment, use:
# > source deactivate
#

$ conda activate ete3
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If your shell is Bash or a Bourne variant, enable conda for the current user with

    $ echo ". /Users/kuro/.pyenv/versions/anaconda3-5.3.1/etc/profile.d/conda.sh" >> ~/.bash_profile
・・・・・

早速エラーが出る。言われたように対応して

$ echo ". /Users/kuro/.pyenv/versions/anaconda3-5.3.1/etc/profile.d/conda.sh" >> ~/.bash_profile

$ source ../.bash_profile

$ conda activate ete3

そっけなく

(ete3) (anac1) kuro-Mac:anac1 kurovmax@gmail.com$

とプロンプトが変わり、

$  conda install -c etetoolkit ete3 ete_toolchain
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.5.11
  latest version: 4.12.0
・・・・・
Downloading and Extracting Packages
gettext-0.21.0       | 3.4 MB    | ##################################### | 100% 
pip-21.2.2           | 2.1 MB    | ##################################### | 100% 
mafft-6.861          | 4.8 MB    | ##################################### | 100% 
fasttree-2.1         | 278 KB    | ##################################### | 100% 
mkl_fft-1.3.0        | 175 KB    | ##################################### | 100% 
expat-2.4.4          | 145 KB    | ##################################### | 100% 
setuptools-58.0.4    | 970 KB    | ##################################### | 100% 
mkl_random-1.1.1     | 334 KB    | ##################################### | 100% 
certifi-2021.5.30    | 141 KB    | ##################################### | 100% 
numpy-base-1.19.2    | 5.0 MB    | ##################################### | 100% 
lxml-4.6.3           | 1.3 MB    | ##################################### | 100% 
sip-4.19.8           | 252 KB    | ##################################### | 100% 
libiconv-1.16        | 1.3 MB    | ##################################### | 100% 
kalign-2.03          | 261 KB    | ##################################### | 100% 
scipy-1.5.2          | 17.3 MB   | ##################################### | 100% 
pcre-8.45            | 221 KB    | ##################################### | 100% 
ete3-3.1.2           | 2.1 MB    | ##################################### | 100% 
argtable2-2.13       | 2.7 MB    | ##################################### | 100% 
dbus-1.13.18         | 550 KB    | ##################################### | 100% 
paml-4.8             | 7.0 MB    | ##################################### | 100% 
muscle-3.8.31        | 1.8 MB    | ##################################### | 100% 
libxslt-1.1.34       | 534 KB    | ##################################### | 100% 
mkl-service-2.3.0    | 45 KB     | ##################################### | 100% 
pyqt-5.9.2           | 4.4 MB    | ##################################### | 100% 
phylobayes-4.1c      | 27.3 MB   | ##################################### | 100% 
glib-2.69.1          | 3.3 MB    | ##################################### | 100% 
phyml-20160115.patch | 3.9 MB    | ##################################### | 100% 
raxml-8.2.11         | 10.4 MB   | ##################################### | 100% 
mkl-2019.4           | 155.2 MB  | ##################################### | 100% 
dialigntx-1.0.2      | 2.4 MB    | ##################################### | 100% 
libgcc-4.8.5         | 302 KB    | ##################################### | 100% 
pmodeltest-1.4       | 729 KB    | ##################################### | 100% 
t_coffee-11.00       | 10.5 MB   | ##################################### | 100% 
slr-1.4.3            | 862 KB    | ##################################### | 100% 
iqtree-1.5.5         | 11.2 MB   | ##################################### | 100% 
clustalo-1.2.4       | 1.4 MB    | ##################################### | 100% 
python-3.6.13        | 20.3 MB   | ##################################### | 100% 
ete_toolchain-3.0.0  | 4 KB      | ##################################### | 100% 
llvm-openmp-12.0.0   | 300 KB    | ##################################### | 100% 
trimal-1.4           | 1.4 MB    | ##################################### | 100% 
intel-openmp-2022.0. | 1.2 MB    | ##################################### | 100% 
numpy-1.19.2         | 20 KB     | ##################################### | 100% 
libxml2-2.9.12       | 1.2 MB    | ##################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

$ ete3 version
3.1.2 Tools path: /Users/kuro/.pyenv/versions/anaconda3-5.3.1/envs/ete3/lib/python3.6/site-packages/ete3-3.1.2-py3.7.egg/ete3/tools

$ ete3 build check
Current Toolchain path: /Users/kuro/.pyenv/versions/anaconda3-5.3.1/envs/ete3/bin/ete3_apps/bin 
Current Toolchain version: unknown
       clustalo: MISSING
         codeml: OK - AAML in paml version 4.8a, July 2014
Dialign-tx not supported in OS X
       fasttree: OK - Usage for FastTree version 2.1.8 Double precision (No SSE3), OpenMP (1 threads):
         iqtree: OK - IQ-TREE multicore version 1.5.5 for Mac OS X 64-bit built Jun  2 2017
         kalign: OK - Kalign version 2.04, Copyright (C) 2004, 2005, 2006 Timo Lassmann
          mafft: OK - MAFFT v6.861b (2011/09/24)
         muscle: OK - MUSCLE v3.8.31 by Robert C. Edgar
          phyml: OK - . This is PhyML version 20160115.
     pmodeltest: OK - pmodeltest.py v1.4
          raxml: OK - This is RAxML version 8.2.11 released by Alexandros Stamatakis on June 2017.
 raxml-pthreads: OK - This is RAxML version 8.2.11 released by Alexandros Stamatakis on June 2017.
         readal: OK - readAl v1.4.rev6 build[2012-02-02]
            slr: OK - # SLR "Sitewise Likelihood Ratio" selection detection program. Version 1.4.3
         statal: OK - statAl v1.4.rev6 build[2012-02-02]
        tcoffee: OK - PROGRAM: T-COFFEE Version_11.00.8cbe486 (2014-08-12 22:05:29 - Revision 8cbe486 - Build 477)
         trimal: OK - trimAl v1.4.rev6 build[2012-02-02]

WARNING: 1 external tools seem to be missing or unfunctional
Install using conda (recomended):
 conda install -c etetoolkit ete3_external_apps
or manually compile by running:
 ete3 upgrade-external-tools

インストールできたのか?。
clustaloが入ってないよ、と言っている気がする。

Clustal Omega - fast, accurate, scalable multiple sequence alignment for proteins

ここでMac用バイナリをダウンロードしてきて名前をclustaloに変える。そして
/Users/kuro/.pyenv/versions/anaconda3-5.3.1/envs/ete3/bin/ete3_apps/bin/
に移動させてchmod 755としてやれば

o$ ete3 build check
Current Toolchain path: /Users/kuro/.pyenv/versions/anaconda3-5.3.1/envs/ete3/bin/ete3_apps/bin 
Current Toolchain version: unknown
       clustalo: OK - 1.2.3
         codeml: OK - AAML in paml version 4.8a, July 2014
Dialign-tx not supported in OS X
       fasttree: OK - Usage for FastTree version 2.1.8 Double precision (No SSE3), OpenMP (1 threads):
         iqtree: OK - IQ-TREE multicore version 1.5.5 for Mac OS X 64-bit built Jun  2 2017
         kalign: OK - Kalign version 2.04, Copyright (C) 2004, 2005, 2006 Timo Lassmann
          mafft: OK - MAFFT v6.861b (2011/09/24)
         muscle: OK - MUSCLE v3.8.31 by Robert C. Edgar
          phyml: OK - . This is PhyML version 20160115.
     pmodeltest: OK - pmodeltest.py v1.4
          raxml: OK - This is RAxML version 8.2.11 released by Alexandros Stamatakis on June 2017.
 raxml-pthreads: OK - This is RAxML version 8.2.11 released by Alexandros Stamatakis on June 2017.
         readal: OK - readAl v1.4.rev6 build[2012-02-02]
            slr: OK - # SLR "Sitewise Likelihood Ratio" selection detection program. Version 1.4.3
         statal: OK - statAl v1.4.rev6 build[2012-02-02]
        tcoffee: OK - PROGRAM: T-COFFEE Version_11.00.8cbe486 (2014-08-12 22:05:29 - Revision 8cbe486 - Build 477)
         trimal: OK - trimAl v1.4.rev6 build[2012-02-02]

これでいいですね。DialignはMacでは使えないらしいのでどうにもならん。

とまあインストールできたように見えるんだけど、どうしたわけか動かないんだよなETE3 toolkit。バカバカしくなってきたから撤退。