这里记录在Ubuntu 18.04上安装PythonOCC-core的整个过程,方便以后复现。
快速安装
Python 3.6 & 3.7
# first create an environment
conda create --name=whatever-name python=3.7
source activate whatever-name
conda install -c dlr-sc pythonocc-core=7.4.0
Python 3.7 & 3.8
# first create an environment
conda create --name=whatever-name python=3.8
source activate whatever-name
conda install -c conda-forge pythonocc-core=7.4.0
以上两种情况均采用conda安装,十分方便快速,但是有时conda又显得臃肿,尽管我用的是miniconda。
编译安装
依赖安装
- Python 3.6.x or 3.7.x or 3.8.x
如何安装这里不做赘述,一般Ubuntu 18.04会自带Python 3.6.9
# 环境依赖安装
sudo apt-get install software-properties-common
sudo apt-get install libtool autoconf automake gfortran gdebi
sudo apt-get install gcc-multilib libxi-dev libxmu-dev libxmu-headers
sudo apt-get install libx11-dev mesa-common-dev libglu1-mesa-dev
sudo apt-get install libfontconfig1-dev
# Freetype 安装(2.8)
sudo apt install freetype2-demos
# Tcl/TK 安装 (8.6)
sudo apt-get install tcl tcl-dev tk tk-dev
# OpenCascade 安装
下载OpenCascade源码从https://www.opencascade.com/content/download-center
tar xf opencascade-7.4.0.tar.gz
mkdir tmp
cd tmp
cmake ../opencascade-7.4.0
make
make install
# SWIG 安装
sudo apt-get install -y swig
PythonOCC安装
git clone git://github.com/tpaviot/pythonocc-core.git
cd pythonocc-core
mkdir cmake-build
cd cmake-build
cmake ..
make
sudo make install
注意事项
由于pythonocc编译时cmake版本需要在3.14以上,而Ubuntu 18.04采用apt直接安装的版本低于此版本,需要重新安装。
# 卸载旧的cmake
sudo apt purge --auto-remove cmake
# Obtain a copy of the signing key
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
# For Ubuntu Bionic Beaver (18.04)
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
# Update and install
sudo apt update
sudo apt install cmake
参考