Hi Quaoar, thanks a lot for these great tutorials. I am looking forward to the next episodes!
It is actually straight forward to get started with PythonOCC, but it requires the conda package manager. Here is a guide:
Get conda package manager
Install the anaconda distribution (individual edition). You can obtain an installer for your OS here. The installation will give you the conda package manager and a base environment containing python together with a lot of commonly used python packages for data science (e.g. numpy, matplotlib and more).
Note:
If you don't want the additional bloat (i.e. data science packages) comming with a full anaconda installation (which seems unnecessary if the only purpose is to install PythonOCC), then you may want to install miniconda instead. I imagine the installation procedure is very similar, but I never tried miniconda. From a quick google search it seems like you can get an installer to miniconda here
Obtaining PythonOCC using conda
Open your favorite shell (that has conda in its path), and run the following three commands (you may be prompted for a y/n answer):
First command can be omitted if you don't want to create a separate environment for PythonOCC. In that case the second command should be changed to 'conda activate base'.
You are now good to go. You can test the installation by activating the environment containing PythonOCC (e.g. 'conda activate base' or 'conda activate pyoccenv') and run
Resources
PythonOCC has a lot of examples in one of their github repos which you might find interesting. You can find them here:
https://github.com/tpaviot/pythonocc-demos
The examples requires a gui backend (for instance PySide2) to be installed in the conda environment containing PythonOCC. One warning, though, I had to make a small change (using PySide2 backend) to get the examples to work (can't remember exactly what, but when having the error message it was quite easy to google).
Alternatives to PythonOCC
PythonOCC seems to have the largest community and a lot of good examples, but in case you are interested there are two other projects (that I know of) that provides python bindings to OpenCascade:
It is actually straight forward to get started with PythonOCC, but it requires the conda package manager. Here is a guide:
Get conda package manager
Install the anaconda distribution (individual edition). You can obtain an installer for your OS here. The installation will give you the conda package manager and a base environment containing python together with a lot of commonly used python packages for data science (e.g. numpy, matplotlib and more).
Note:
- The windows installation wizard will by default not add anaconda to your path (but there is a non-recommended option to do so (which I always use, alternatively you can use the shell coming with anaconda))
- Depending on your shell/terminal you may have to run some initialization script after installation.
If you don't want the additional bloat (i.e. data science packages) comming with a full anaconda installation (which seems unnecessary if the only purpose is to install PythonOCC), then you may want to install miniconda instead. I imagine the installation procedure is very similar, but I never tried miniconda. From a quick google search it seems like you can get an installer to miniconda here
Obtaining PythonOCC using conda
Open your favorite shell (that has conda in its path), and run the following three commands (you may be prompted for a y/n answer):
- conda create -n pyoccenv python=3.8
- conda activate pyoccenv
- conda install -c conda-forge pythonocc-core
First command can be omitted if you don't want to create a separate environment for PythonOCC. In that case the second command should be changed to 'conda activate base'.
You are now good to go. You can test the installation by activating the environment containing PythonOCC (e.g. 'conda activate base' or 'conda activate pyoccenv') and run
- python -c "import OCC; print(OCC.VERSION)"
Resources
PythonOCC has a lot of examples in one of their github repos which you might find interesting. You can find them here:
https://github.com/tpaviot/pythonocc-demos
The examples requires a gui backend (for instance PySide2) to be installed in the conda environment containing PythonOCC. One warning, though, I had to make a small change (using PySide2 backend) to get the examples to work (can't remember exactly what, but when having the error message it was quite easy to google).
Alternatives to PythonOCC
PythonOCC seems to have the largest community and a lot of good examples, but in case you are interested there are two other projects (that I know of) that provides python bindings to OpenCascade: