網頁

顯示具有 Mac 標籤的文章。 顯示所有文章
顯示具有 Mac 標籤的文章。 顯示所有文章

2020年8月25日 星期二

RDkit透過conda安裝

執行下面其中一項指令

$ conda install -c rdkit rdkit
$ conda install -c rdkit/label/nightly rdkit
$ conda install -c rdkit/label/attic rdkit
$ conda install -c rdkit/label/beta rdkit



參考
https://anaconda.org/rdkit/rdkit

2020年3月28日 星期六

Mac install Packmol

1.先安裝gfortran
$ brew cask install gfortran

2.下載檔案
http://m3g.iqm.unicamp.br/packmol/download.shtml

3.解壓縮
$ tar -xvzf packmol.tar.gz

4.讓腳本可執行
$ chmod +x ./configure

5.執行腳本
$ ./configure

6.設定packmol環境
$ sudo cp packmol /usr/local/bin

7.編譯packmol
$ packmol < mixture.inp

2020年3月9日 星期一

Lammps安裝過程

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
camlp5                      lablgtk                     menhir                      ocaml                       ocaml-num                   ocamlsdl
inadyn                      libexosip                   mkvtoolnix                  ocaml-findlib               ocamlbuild                  verilator
==> Deleted Formulae
camlp4
==> Updated Casks
homebrew/cask/amethyst                    homebrew/cask/freeplane                   homebrew/cask/mucommander                 homebrew/cask/tinymediamanager
homebrew/cask/base                        homebrew/cask/j                           homebrew/cask/mudlet                      homebrew/cask/veusz
homebrew/cask/blitz                       homebrew/cask/keystore-explorer           homebrew/cask/numi                        homebrew/cask/xamarin-profiler
homebrew/cask/burn                        homebrew/cask/kode54-cog                  homebrew/cask/pinegrow                    homebrew/cask/yinxiangbiji
homebrew/cask/daisydisk                   homebrew/cask/mcgimp                      homebrew/cask/psychopy
homebrew/cask/electrocrud                 homebrew/cask/mellow                      homebrew/cask/refined-github-safari

==> Installing dependencies for lammps: hwloc, libevent, open-mpi, fftw and kim-api
==> Installing lammps dependency: hwloc
==> Downloading https://homebrew.bintray.com/bottles/hwloc-2.1.0.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/94/94e4e238c45da330b53fde9c622e74a2dfabd00a17f37fa1807b1d828452759d?__gda__=exp=1583746103~hmac=200ec34b4765b09c65c523c
######################################################################## 100.0%
==> Pouring hwloc-2.1.0.catalina.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
🍺  /usr/local/Cellar/hwloc/2.1.0: 881 files, 9.5MB
==> Installing lammps dependency: libevent
==> Downloading https://homebrew.bintray.com/bottles/libevent-2.1.11_1.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/9d/9d262f9ffb2268340a89c713826d8ca068bcac06c30baf49e6184ab4660d977a?__gda__=exp=1583746109~hmac=a9d25e6511b5ddd7eeaa86c
######################################################################## 100.0%
==> Pouring libevent-2.1.11_1.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/libevent/2.1.11_1: 1,063 files, 5MB
==> Installing lammps dependency: open-mpi
==> Downloading https://homebrew.bintray.com/bottles/open-mpi-4.0.3.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/3b/3b143cf02a5345bb0d4df0777d3a34f806ff7fb66dc5d21993b8c4f218722ac7?__gda__=exp=1583746115~hmac=253bae48c6c40c68026dc37
######################################################################## 100.0%
==> Pouring open-mpi-4.0.3.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/open-mpi/4.0.3: 752 files, 11.3MB
==> Installing lammps dependency: fftw
==> Downloading https://homebrew.bintray.com/bottles/fftw-3.3.8_1.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/27/271f7a5febd92b8757948c86fa24546aca9025087406056b7cf4036ca97b29e4?__gda__=exp=1583746121~hmac=4b173984e6ec8b297aa0ec8
######################################################################## 100.0%
==> Pouring fftw-3.3.8_1.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/fftw/3.3.8_1: 73 files, 14.8MB
==> Installing lammps dependency: kim-api
==> Downloading https://homebrew.bintray.com/bottles/kim-api-2.1.3.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/ae/ae59f45bf8d539f1b633120cdb942c2a0a0f1880eee4ee91981f268792e1b1c4?__gda__=exp=1583746126~hmac=464da1ff6f45e08326d29d8
######################################################################## 100.0%
==> Pouring kim-api-2.1.3.catalina.bottle.tar.gz
Warning: kim-api dependency gcc was built with a different C++ standard
library (libstdc++ from clang). This may cause problems at runtime.
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completions and functions have been installed to:
  /usr/local/share/zsh/site-functions

Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/kim-api
==> Summary
🍺  /usr/local/Cellar/kim-api/2.1.3: 1,285 files, 21.6MB
==> Installing lammps
==> Downloading https://homebrew.bintray.com/bottles/lammps-2019-08-07.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/60/604056c80bb3b36f0a1644388bff26f2bcdc3e2f2541247e9a7ce941b20e9bcc?__gda__=exp=1583746133~hmac=2bd684fb81d50cc717258b5
######################################################################## 100.0%
==> Pouring lammps-2019-08-07.catalina.bottle.tar.gz
Warning: lammps dependency gcc was built with a different C++ standard
library (libstdc++ from clang). This may cause problems at runtime.
🍺  /usr/local/Cellar/lammps/2019-08-07: 5,788 files, 335.5MB
==> Caveats
==> hwloc
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> kim-api
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completions and functions have been installed to:
  /usr/local/share/zsh/site-functions

Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/kim-api

Mac install tensorflow 2.1.0, Keras 2.3.1, scikit-learn, and RDkit

Tensorflow:
我選擇system安裝,不使用virtual environment

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
$ brew update
$ brew install python
$ sudo pip3 install -U virtualenv
$ pip3 install --user --upgrade tensorflow

如果是python3.7.3版本的話要修改linecache.py

$ sudo vi /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/linecache.py

第48行改成
for mod in list(sys.modules.values()): # for mod in sys.modules.values():

Keras:

$ brew install hdf5
$ brew install graphviz
$ sudo pip3 install pydot (一定要加sudo)
$ vi ~/.bash_profile
export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH
$ source ~/.bash_profile
$ sudo pip3 install keras (一定要加sudo)

scikit-learn:
$ pip3 install -U scikit-learn

RDkit:
$ brew tap rdkit/rdkit
$ brew install rdkit

If you need to have icu4c first in your PATH run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc

For compilers to find icu4c you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c/include"

==> openblas
openblas is keg-only, which means it was not symlinked into /usr/local,
because macOS provides BLAS and LAPACK in the Accelerate framework.

For compilers to find openblas you may need to set:
  export LDFLAGS="-L/usr/local/opt/openblas/lib"
  export CPPFLAGS="-I/usr/local/opt/openblas/include"

==> rdkit
      You may need to add RDBASE to your environment variables.
      For Bash, put something like this in your $HOME/.bashrc:
        export RDBASE=/usr/local/share/RDKit

參考
https://github.com/rdkit/homebrew-rdkit

Mac執行tensorflow發生RuntimeError: dictionary changed size during iteration

問題:
Homebrew的python3版本是3.7.3
在執行tensorflow時出現以下

.
.
.
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/linecache.py", line 48, in getlines
    for mod in sys.modules.values():

RuntimeError: dictionary changed size during iteration

解決:
$ sudo vi /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/linecache.py

第48行改成
for mod in list(sys.modules.values()): # for mod in sys.modules.values():



參考
http://www.kaierlong.me/blog/post/kaierlong/tensorflow-2.0-%E9%94%99%E8%AF%AF-RuntimeError-dictionary-changed-size-during-iteration

2019年12月8日 星期日

VIM and Python – A Match Made in Heaven

https://realpython.com/vim-and-python-a-match-made-in-heaven/
https://zhuanlan.zhihu.com/p/36014406

沒有安裝的套件有:
Ditch the Mouse
Buffers
Flagging Unnecessary Whitespace
Auto-Complete
Color Schemes
Powerline
System Clipboard
VIM in the Shell


File Browsing的程式碼
let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
下面多加一行程式碼設定F2啟動File Browsing功能
map <F2> :NERDTreeToggle<CR>

2019年8月3日 星期六

Mac中Git忽略.DS_Store文件

建立gitignore文件
$ touch ~/.gitignore_global

$ vi ~/.gitignore_global
寫入
# Mac OS
**/.DS_Store

配置gitignore文件
$ git config --global core.excludesfile ~/.gitignore_global



參考
https://orianna-zzo.github.io/sci-tech/2018-01/mac%E4%B8%ADgit%E5%BF%BD%E7%95%A5.ds_store%E6%96%87%E4%BB%B6/

2019年5月13日 星期一

2019年5月6日 星期一

Mac Keras+RDKit

因為tensorflow安裝以及RDKit利用Homebrew安裝都是呼叫同一個呼叫/usr/local/bin裡的python3,所以使用這兩個函式庫之前要先輸入

$ which python3

來確認是否呼叫正確位置的python3。不是的話,由於先前安裝RDKit時,有設定"export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH"在~/.bash_profile,因此輸入

$ source ~/.bash_profile

再確認python3是否更改為"/usr/local/bin/python3"


2019年5月4日 星期六

ValueError: Object arrays cannot be loaded when allow_pickle=False

Using TensorFlow backend.
Traceback (most recent call last):
  File "test_keras.py", line 13, in <module>
    (X_train, y_train), (X_test, y_test) = imdb.load_data(num_words=top_words)
  File "/usr/local/lib/python3.6/site-packages/keras/datasets/imdb.py", line 59, in load_data
    x_train, labels_train = f['x_train'], f['y_train']
  File "/usr/local/lib/python3.6/site-packages/numpy/lib/npyio.py", line 262, in __getitem__
    pickle_kwargs=self.pickle_kwargs)
  File "/usr/local/lib/python3.6/site-packages/numpy/lib/format.py", line 692, in read_array
    raise ValueError("Object arrays cannot be loaded when "
ValueError: Object arrays cannot be loaded when allow_pickle=False


numpy版本不符合當前代碼,更新Numpy版本1.16.3,導致加載數據過程中出錯,

$ pip install numpy==1.16.2

參考
https://www.twblogs.net/a/5cc61956bd9eee1ac2ed4944

Xcode version must be specified to use an Apple CROSSTOOL

ERROR: /private/var/tmp/_bazel_yangyan-ling/2ce5cc8600b6d4faf46244230a6eedc1/external/local_config_cc/BUILD:58:5: in apple_cc_toolchain rule @local_config_cc//:cc-compiler-armeabi-v7a: Xcode version must be specified to use an Apple CROSSTOOL. If your Xcode version has changed recently, try: "bazel clean --expunge" to re-run Xcode configuration
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted: Analysis of target '@local_config_cc//:cc-compiler-armeabi-v7a' failed; build aborted
INFO: Elapsed time: 0.242s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (5 packages loaded, 48 targets configured)
    currently loading: tensorflow/core ... (2 packages)

$ bazel clean --expunge
$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
$ sudo xcodebuild -license
$ bazel clean --expunge

Mac Python3.7.3切換3.6.5_1

$ brew unlink python

安裝3.6.5
$ brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb

$ brew switch python 3.7.3

$ brew switch python 3.6.5_1



參考
https://stackoverflow.com/questions/51726203/installing-python3-6-alongside-python3-7-on-mac

2019年5月3日 星期五

Executing genrule //tensorflow:python_api_gen failed (Exit 1) bash failed: error executing command /bin/bash -c ...

ERROR: /Users/yangyan-ling/tensorflow/tensorflow/BUILD:541:1: Executing genrule //tensorflow:python_api_gen failed (Exit 1) bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
Traceback (most recent call last):
  File "/private/var/tmp/_bazel_yangyan-ling/2ce5cc8600b6d4faf46244230a6eedc1/sandbox/darwin-sandbox/5695/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/tools/api/generator/create_python_api.runfiles/org_tensorflow/tensorflow/tools/api/generator/create_python_api.py", line 27, in <module>
    from tensorflow.python.util import tf_decorator
  File "/private/var/tmp/_bazel_yangyan-ling/2ce5cc8600b6d4faf46244230a6eedc1/sandbox/darwin-sandbox/5695/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/tools/api/generator/create_python_api.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 63, in <module>
    from tensorflow.python.framework.framework_lib import *  # pylint: disable=redefined-builtin
  File "/private/var/tmp/_bazel_yangyan-ling/2ce5cc8600b6d4faf46244230a6eedc1/sandbox/darwin-sandbox/5695/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/tools/api/generator/create_python_api.runfiles/org_tensorflow/tensorflow/python/framework/framework_lib.py", line 52, in <module>
    from tensorflow.python.framework.importer import import_graph_def
  File "/private/var/tmp/_bazel_yangyan-ling/2ce5cc8600b6d4faf46244230a6eedc1/sandbox/darwin-sandbox/5695/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/tools/api/generator/create_python_api.runfiles/org_tensorflow/tensorflow/python/framework/importer.py", line 27, in <module>
    from tensorflow.python.framework import function
  File "/private/var/tmp/_bazel_yangyan-ling/2ce5cc8600b6d4faf46244230a6eedc1/sandbox/darwin-sandbox/5695/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/tools/api/generator/create_python_api.runfiles/org_tensorflow/tensorflow/python/framework/function.py", line 37, in <module>
    from tensorflow.python.ops import variable_scope as vs
  File "/private/var/tmp/_bazel_yangyan-ling/2ce5cc8600b6d4faf46244230a6eedc1/sandbox/darwin-sandbox/5695/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/tools/api/generator/create_python_api.runfiles/org_tensorflow/tensorflow/python/ops/variable_scope.py", line 24, in <module>
    import enum  # pylint: disable=g-bad-import-order
ImportError: No module named enum
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 3067.684s, Critical Path: 183.55s, Remote (0.00% of the time): [queue: 0.00%, setup: 0.00%, process: 0.00%]
INFO: 5694 processes: 5691 darwin-sandbox, 3 local.
FAILED: Build did NOT complete successfully


$ pip install enum34
$ pip uninstall enum


參考
https://github.com/tensorflow/serving/issues/893

Mac install tensorflow-1.9.0+Keras

官方版的安裝對Mac有許多限制,如果不想利用虛擬環境跑TensorFlow的話,以下是安裝流程。

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer


參考
https://vyspiansky.github.io/2018/09/28/xcodebuild-requires-xcode/