推荐使用Anaconda 或者pip安装

Nipype安装

1、创建一个名为nipype的虚拟环境

  1. conda create -n nipypes python=3.8

激活虚拟环境

  1. conda activate nipypes

2、安装nipype包

conda方式

  1. conda search nipype --channel conda-forge
  1. conda install --channel conda-forge nipype

pip方式

  1. pip install nipype

3、安装其他的依赖包

这一步很容易出错,pygraphvizgraphviz这两个包特别不好装

对于Ubuntu用户

  1. #Install packages with pip
  2. pip install nibabel rdflib nipy dipy
  3. #Install graphviz and pygraphviz separately
  4. sudo apt-get install graphviz libgraphviz-dev
  5. pip install --upgrade pygraphviz graphviz

对于CentOS的用户

如果出现pip install pygraphviz: No package 'libcgraph' found
的错误,可以参考下面这个,不一定有用!

  1. yum list available graphviz*
  2. select the appropriate package
  3. sudo yum install ‘graphviz-devel.x86_64’
  4. pip install pygraphviz
    如果无效的话参考我的Ref.2或者Google或者在GitHub issue里看能不能找到

检测是否安装成功

在创建的虚拟环境中:

先安装pytest库

  1. pip install pytest

测试

  1. python -c "import nipype; print(nipype.__version__)"
  2. python -c "import nipype; nipype.test()"

发现报错

  1. =========================== short test summary info ============================
  2. ERROR anaconda3/envs/nipypes/lib/python3.8/site-packages/nipype/sphinxext/apidoc/__init__.py
  3. ERROR anaconda3/envs/nipypes/lib/python3.8/site-packages/nipype/sphinxext/apidoc/docstring.py
  4. !!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!
  5. ======================== 16 warnings, 2 errors in 9.72s ========================

找到错误原因:

  1. ==================================== ERRORS ====================================
  2. ________________ ERROR collecting sphinxext/apidoc/__init__.py _________________
  3. anaconda3/envs/nipypes/lib/python3.8/site-packages/nipype/sphinxext/apidoc/__init__.py:5: in <module>
  4. from sphinxcontrib.napoleon import (
  5. E ModuleNotFoundError: No module named 'sphinxcontrib.napoleon'
  6. ________________ ERROR collecting sphinxext/apidoc/docstring.py ________________
  7. anaconda3/envs/nipypes/lib/python3.8/importlib/__init__.py:127: in import_module
  8. return _bootstrap._gcd_import(name[level:], package, level)
  9. <frozen importlib._bootstrap>:1014: in _gcd_import
  10. ???
  11. <frozen importlib._bootstrap>:991: in _find_and_load
  12. ???
  13. <frozen importlib._bootstrap>:961: in _find_and_load_unlocked
  14. ???
  15. <frozen importlib._bootstrap>:219: in _call_with_frames_removed
  16. ???
  17. <frozen importlib._bootstrap>:1014: in _gcd_import
  18. ???
  19. <frozen importlib._bootstrap>:991: in _find_and_load
  20. ???
  21. <frozen importlib._bootstrap>:975: in _find_and_load_unlocked
  22. ???
  23. <frozen importlib._bootstrap>:671: in _load_unlocked
  24. ???
  25. <frozen importlib._bootstrap_external>:783: in exec_module
  26. ???
  27. <frozen importlib._bootstrap>:219: in _call_with_frames_removed
  28. ???
  29. anaconda3/envs/nipypes/lib/python3.8/site-packages/nipype/sphinxext/apidoc/__init__.py:5: in <module>
  30. from sphinxcontrib.napoleon import (
  31. E ModuleNotFoundError: No module named 'sphinxcontrib.napoleon'
  32. =============================== warnings summary ===============================

安装sphinxcontrib-napoleon这个包

  1. pip install sphinxcontrib-napoleon
  2. pip install -U Sphinx

Reference

http://miykael.github.io/nipype-beginner-s-guide/installation.html#ants
https://stackoverflow.com/questions/40528048/pip-install-pygraphviz-no-package-libcgraph-found