主要记录用 Anaconda
安装 fealpy,既然要用 Anaconda
那么首先了解一下 Anaconda
到底是什么,可以参考 Anaconda 完全入门指南,以及熟悉一下 conda 的命令操作 (conda 常用命令) 可以帮助理解.
我自己比较喜欢把不同的事情分开管理,所以这里单独创建一个名为 myFealpy
的 virtual environment
:
conda create -n myFealpy python=3
接下来就是安装 fealpy,完全按照 fealpy 中 Ubuntu 下的第 1, 2 步安装步骤:
- please install the python envieronment.
$ sudo apt install git # The version control tool $ sudo apt install python3 # The python3 interpretor $ sudo apt install python3-pip # The PyPA recommended tool for installing Python packages. $ sudo apt install python3-tk # Python interface to Tcl/Tk used by matplotlib
- clone the latest fealpy from github or gitlab:
$ git clone https://github.com/weihuayi/fealpy.git
(假定第1
,2
步已经完成, 主要是安装 fealpy 的依赖库)
这里需要注意一下, 在最新的版本中可以按照如下的方式来安装 fealpy 依赖库 (下面命令中 -c conda-forge
可以去掉, 但是最好不要去掉)
$ conda install -n myFealpy -c conda-forge meshio
$ conda install -n myFealpy -c conda-forge meshpy
$ conda install -n myFealpy -c conda-forge pyamg
$ conda install -n myFealpy -c conda-forge pyfftw
$ conda install -n myFealpy -c conda-forge vtk
$ conda install -n myFealpy -c conda-forge mpi4py
$ conda install -n myFealpy -c conda-forge petsc
$ conda install -n myFealpy -c conda-forge petsc4py
然后我们看第3
步,Ubuntu
下 cd fealpy/
, 然后 sudo -H pip3 install -e ./
,但是这里我们需要指定 pip
的位置(我的 Anaconda
直接装在了根目录下 /anaconda3
):
(或者先 conda activate myFealpy
切换到 myFealpy 的 virtual env 下, 这样可以直接用 sudo -H pip install -e ./
就可以了)
sudo -H /anaconda3/envs/myFealpy/bin/pip install -e ./
可以通过 conda info --env
或 conda env list
来查看 ‘‘env’’ 的具体安装路径.
另外需要注意的一点是 fealpy 给出了两种安装命令
sudo -H /anaconda3/envs/myFealpy/bin/pip install -e ./
和
sudo -H /anaconda3/envs/myFealpy/bin/pip install ./
但是我只有在用 sudo -H /anaconda3/envs/myFealpy/bin/pip install -e ./
安装时才能运行里面的 examples,而用 sudo -H /anaconda3/envs/myFealpy/bin/pip install ./
安装后,运行时总是出错:No module named 'fealpy'
.
另外想要运行多边形网格算例 (如 VEM 算例),需要安装 meshpy,参见 meshpy 官网给的说明
- Download MeshPy
$ cd MeshPy-VERSION # if you're not there already
$ ./configure
$ python setup.py install
而我自己则利用下面命令安装
sudo /anaconda3/envs/myFealpy/bin/python3 setup.py install
但是 macOS 下安装 meshpy
会出问题,具体问题以及解决方法见:Some meshpy installation issue on MacOS mojave 10.14
I think the installation guide for macOS is quite uncompleted?
Following the guide for Linux, changing the command to brew for most packages, I had the following error while installing meshpy by runningpip
installmeshpy
ld: library not found for -lstdc++ clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command 'g++' failed with exit status 1
This error can be caused by Xcode being not up-to-date, run
xcode-select --install
will do. Then runbrew config
to make sure CLT has a version.
After installing the CLT of Xcode, go to/Library/Developer/CommandLineTools/Packages/
, execute the package theremacOS_SDK_headers_for_macOS_10.14.pkg
would addlstdc++
back to the header.
Now all the.ipynb
files in doc can be run without an issue.
以及安装 pyfftw
到 myFealpy
下
sudo conda install -n myFealpy -c conda-forge pyfftw