很早之前用 Anaconda3 (conda 版本 4.6.8) 安装过一次 Fenics (conda create -n fenicsproject -c conda-forge fenics),安装后可以成功运行算例。
这几天重新安装的 Anaconda3 (conda 版本 4.7.10) 然后重新安装 Fenics (conda create -n fenicsproject -c conda-forge fenics),安装后运行到 from fenics import * 总是提示错误:
(fenicsproject) MacBookPro:~ xxx$ python Python 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 14:38:56) [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from fenics import * Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Applications/anaconda3/envs/fenicsproject/lib/python3.7/site-packages/fenics/__init__.py", line 7, in <module> from dolfin import * File "/Applications/anaconda3/envs/fenicsproject/lib/python3.7/site-packages/dolfin/__init__.py", line 34, in <module> from .cpp import __version__ ImportError: dlopen(/Applications/anaconda3/envs/fenicsproject/lib/python3.7/site-packages/dolfin/cpp.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libdmumps-5.1.2.dylib Referenced from: /Applications/anaconda3/envs/fenicsproject/lib/libpetsc.3.11.dylib Reason: image not found然后卸载 Anaconda3,重装,仍然是这个错误,后来在 Fenics 论坛提问 Errors in calling `from fenics import *`,有人给出了解答
Try this:
conda create -n fenics2018 -c conda-forge fenics=2018
This worked for me (macOS Mojave 10.14.6), what did not work was fenics=2019. You can also try fenics=2017 but then I would suggest using
conda create -n fenics2017 -c conda-forge fenics=2017 scipy matplotlib=2.2.3 python=3.5 mpi4py sympy=1.1.1
Actually, I use:
conda create -n fenics2018 -c conda-forge fenics=2018 matplotlib scipy python=3.7 sympy spyder jupyter
and if you also want spyder and jupyter, then I had to reset spyder (the first time I opened spyder it crashed and said that I have to reset it. Then it worked). For jupyter I also had to install nb_conda:
conda install nb_conda
Hope this works for you.
edit: I also tried to launch Anaconda, changed the environment there and selected Spyder, this did not work for me. Uninstalled everything and installed miniconda
后面采取了 conda create -n fenics2018 -c conda-forge fenics=2018 matplotlib scipy python=3.7 sympy 这种重新建立了 fenics2018 的 virtual environment,安装完 fenics2018 后,调用 fenics2018 的 Python 解释器跑算例,可以运行了,但是总是 furture warning。
因为有 furture warning,所以最终还是想去掉这个 warning, 而从最开始提示的错误中可以看出可能与 mumps 有关,在 Anaconda 中的两个 virtual environment 中搜索 mumps 发现: 在 fenics2018 中有 mumps-mpi 和 mumps-include; 而 fenicsproject 中只有 mumps-mpi。
所以尝试在 fenicsproject 中安装 mumps-include(参考 https://anaconda.org/conda-forge/mumps-include): To install this package with conda run one of the following:
conda install -c conda-forge mumps-include conda install -c conda-forge/label/gcc7 mumps-include conda install -c conda-forge/label/cf201901 mumps-include然后确实在 fenicsproject 安装上了 mumps-include,但是仍然不能运行算例,提示同样的错误。
我在最开始提到了两次安装的 Anaconda 中 conda 的版本是不同的,其实在最新的 conda (4.7.10) 版本下安装 Fenics (conda create -n fenicsproject -c conda-forge fenics) 有个 warning: Solving environment: failed with current_repodata.json, will retry with next repodata source. 后来参考 Solving environment: failed with current_repodata.json, will retry with next repodata source. 中将 conda 从 4.7 降级到 4.6 版本
conda config --set allow_conda_downgrades true conda install conda=4.6.14
然后删掉了 Anaconda 中的 fenicsproject virtual environment 重新安装,conda create -n fenicsproject -c conda-forge fenics
最后可以用 fenicsproject 成功运行 Fenics 算例。
可能是 conda 版本的问题,目前有的问题如下:
Solving environment: failed with current_repodata.json, will retry with next repodata source. UnsatisfiableError: #9004Conda doesn´t work after update conda #8863