A couple of days after Ubuntu 10.04 was released, Oliver Borm contributed a package for pythonOCC-0.4 (see https://launchpad.net/~cae-team/+archive/ppa). Here is how to proceed to get it run in 5 steps and less than 10 minutes of your precious time.
The following results were obtained from a new installation of Ubuntu 10.04 from the original 32 bit CDROM, on a Virtual Box 3.1.6 machine.
Step 1 : set a new package source.
Insert the following line in the source field:
deb http://ppa.launchpad.net/cae-team/ppa/ubuntu lucid main
Step 2 : search/install the python-occ package
From the Synaptic Package Manager utility, search for the python-occ package :
Mark python-occ for installation :
Wait for the download to be completed :
Step 3 : set the CSF_GraphicShr env variable
The CSF_GraphicShr variable must point to /usr/lib/libTKOpenGl-6.3.0.so :
Step 4 : install a GUI manager
You can choose PyQt4 or wxPython. I rather user PyQt4 :
Step 5 : run the HelloWorld example
You’re ready to run the following example (that creates/displays a box) :
from OCC.BRepPrimAPI import *
display, start_display, add_menu, add_function_to_menu = init_display()
my_box = BRepPrimAPI_MakeBox(10.,20.,30.).Shape()
display.DisplayShape(my_box)
start_display()







A true coming-of-age moment for pythonOCC! A real step forward for open source CAD, CAM, KBE, PLM, CAE, you name it ;’)
Dear Thomas,
Thanks a lot! It works like a charm.
I had (unsuccessfully) been trying to build the whole stuff for 2 hours…
Guillaume
I’ve been working to make the installation process easier. I hope the next pythonocc package for Ubuntu will include meshing and parametric modeling features.
Nice work! I look forward to the meshing and parametric modelling…
I could not run pythonOCC properly. I saved the HelloWorld code into ~/Bureau/pythonocc.py
user@computer:~/Bureau$ python pythonocc.py
resize event for qtBaseViewer
resize event for qtBaseViewer
Display3d class initialization starting …
terminate called after throwing an instance of ‘Aspect_GraphicDeviceDefinitionError’
Abandon
user@computer:~/Bureau$
Moreover, I have to run “export CSF_GraphicShr=/usr/lib/libTKOpenGL-6.3.0.so” each time I open a new terminal. Is this normal?
Regards.
Take care to the case: ‘libTKOpenGl-6.3.0.so’ mixes upper and lower case characters. Use the tab completion feature of your shell to be sure the library name matches the one installed.
Hi
I’ve been trying to do this example for a while now without any success.
When I type:
display, start_display, add_menu, add_function_to_menu = init_display()I get the following error messege:
Traceback (most recent call last):
File "", line 1, in
NameError: name 'display' is not defined
Do you know what that means?
I should probably mention that I’m am an absolute beginner with this kind of CAD programs (only been using AutoCAD for school) and I am not familiar with python programing (or any other programing language then matlab in fact).
best regards,
Axel
Really impressive work, thanks. I just miss some documentation, API docs doesn’t tell much as most of it is empty.
Great work! Now, how do I get PAF working?
>>> from OCC.Display.SimpleGui import *
Traceback (most recent call last):
File “”, line 1, in
from OCC.Display.SimpleGui import *
File “C:\Python26\lib\site-packages\OCC\Display\SimpleGui.py”, line 50, in
raise NameError(‘No backend.’)
NameError: No backend.
>>>
What I can do now?
You have to install a GUI manager : either PyQt or wxPython.
yes, installed a wx. got the yellow box.cool.
Works wonderfully! Thanks a lot for this step-by-step tutorial, I thought I would never manage to get it installed on my Ubuntu…
Nice work!
How can I run all pythonOCC sample files?
python test_gears_sympy.py
Traceback (most recent call last):
File “test_gears_sympy.py”, line 21, in
from OCC.PAF.Context import ParametricModelingContext
File “/usr/lib/pymodules/python2.6/OCC/PAF/Context.py”, line 18, in
from OCC.GEOMImpl import GEOMImpl_Gen
ImportError: No module named GEOMImpl
Thank you for help in advance …
hell of a job !
what I was looking for as a designer/engineer, and hoping for as an improvised python developper !!
Stéphan
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from OCC.Display.SimpleGui import *
>>> from OCC.BRepPrimAPI import *
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/pymodules/python2.6/OCC/BRepPrimAPI.py", line 28, in
_BRepPrimAPI = swig_import_helper()
File "/usr/lib/pymodules/python2.6/OCC/BRepPrimAPI.py", line 24, in swig_import_helper
_mod = imp.load_module('_BRepPrimAPI', fp, pathname, description)
ImportError: libTKjcas-6.3.0.so: cannot open shared object file: No such file or directory
>>>
Where is libTKjcas supposed to come from? I have python-qt4 and python-wxgtk installed. What am I missing?
You must have downloaded/installed the OpenCASCADE library.
The Ubuntu package libopencascade-foundation-dev is supposed to provide this library (according to the documentation for that package anyway) but evidently the –enable-wrappers flag was not used when they built that package.
I have submitted a bug report on launchpad.net (see Bug #694068)
oops! Its the libopencascade-foundation package that is supposed to provide the libTKjcas library, not the libopencascade-foundation-dev mentioned above. Its that package that was compiled without the –enable-wrappers flag. Same issue, different package.
@Steve: libTKjcas is part of a java wrapper over the OCC C++ API. It’s not necessary for pythonOCC. I removed this dependency in the svn trunk and this will not be a required dependency anymore in the next pythonOCC release.
Hi,
Congratulations for the great job done!
I have a problem when trying to run the example, this is what I get:
victor@CHUMAN:~$ export CSF_GraphicShr=/usr/lib/libTKOpenGl-6.3.0.so
victor@CHUMAN:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from OCC.Display.SimpleGui import *
>>> from OCC.BRepPrimAPI import *
>>> display, start_display, add_menu, add_function_to_menu = init_display()
resize event for qtBaseViewer
resize event for qtBaseViewer
Display3d class initialization starting ...
Graphic device created.
Xw_Window created.
Viewer created.
Segmentation fault
victor@CHUMAN:~$
Hi,
I was adding the new repository to my Ubuntu 10.01 system and I got this error when I reloaded my synaptic package manager:
W: GPG error: http://ppa.launchpad.net lucid Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 59B8C7C7E0BD7612
Any advice on what to do?
Richard
Just tried again and it worked \o/
But I have tried the ‘HelloWorld’ example and I got the same output as Victor Chuman (above).
Did you get it to work Victor and if so what did you do?
Richard
Hi,
I get the following error when I run the example.
marcel@marcel-laptop:~$ python test.py
resize event for qtBaseViewer
resize event for qtBaseViewer
Traceback (most recent call last):
File “test.py”, line 3, in
display, start_display, add_menu, add_function_to_menu = init_display()
File “/usr/lib/pymodules/python2.6/OCC/Display/SimpleGui.py”, line 150, in init_display
win.canva.InitDriver()
File “/usr/lib/pymodules/python2.6/OCC/Display/qtDisplay.py”, line 116, in InitDriver
raise “Please set the CSF_GraphicShr environment variable.”
TypeError: exceptions must be old-style classes or derived from BaseException, not str
Any ideas, what I should do to solve this problem?
Regards,
Marcel
Did run the “export CSF_GraphicShr=/usr/lib/libTKOpenGl-6.3.0.so”, now got
marcel@marcel-laptop:~$ python test.py
resize event for qtBaseViewer
resize event for qtBaseViewer
Display3d class initialization starting …
Graphic device created.
Xw_Window created.
Viewer created.
Segmentation fault
Any ideas, what I should do to solve this problem?
Regards,
Marcel
Richard, Victor,
Are you using an intel video card ?
because there is a issue with ubuntu 10.* and intel card and OCC
see http://code.google.com/p/pythonocc/issues/detail?id=24
my error on ubuntu 10.04
>>> display, start_display, add_menu, add_function_to_menu = init_display()
resize event for qtBaseViewer
resize event for qtBaseViewer
Display3d class initialization starting …
terminate called after throwing an instance of ‘Aspect_GraphicDeviceDefinitionError’
Aborted
peter@peter-laptop:~$ my_box = BRepPrimAPI_MakeBox(10.,20.,30.).Shape()
bash: syntax error near unexpected token `(‘
peter@peter-laptop:~$ display.DisplayShape(my_box)
bash: syntax error near unexpected token `my_box’
peter@peter-laptop:~$ start_display()
HI Shirazbj
where are from dear? I want to develop a linux based CAD/CAM and need help in this regard. I want to make a local team. Would you like to email me at zakiulrehman@gmail.com????
Hi!
Do you guys plan to make a package for ubuntu 11.04?
Thanks!
@millie: ubuntu packages are not official parts of pythonocc. We only provide support for OSX and Win packages.
If you are using a intel video card and experiencing the seg fault problem:
I circumvented it by installing
libgl1-mesa-swx11. Now my system is only doing software rastering, but at least it works.Btw: I’m building a pythonocc-0.5 packages for all major Ubuntu releases. Get them as simple as:
sudo apt-add-repository ppa:hmeyer/pythoncad
sudo apt-get update
sudo apt-get install python-occ
Feel free to Flattr: http://flattr.com/thing/330866/pythonocc-package-for-Ubuntu
@Henning Such a good news that you overcame the intel driver issue. And thank you so much for packaging pythonocc for ubuntu!
@Henning:
Great! You are the best.
Hello,
I was analyzing pythonOCC and it looks great.
At work I use some Linux operating systems where I do not have administrator rights; Is there any method to use something like a portable version of pythonOCC to try it on Linux ?
Thank you,
Best Regards,
Adrian
I am trying to get pyQT4 running on Ubuntu 10.04, and here’s what I get:
1. Package source set OK
2. Python-occ package already installed (version 0.4-1ppa2-lucid1)
3. export CSF_GraphicShr=/usr/lib/libTKOpenGl-6.3.0.so- ok
4. PyQT4 package already installed (version 4.7.2-oubuntu1)
5. Running HelloWorld example:
OK until:
>>> display, start_display, add_menu, add_function_to_menu = init_display()
Display3d class initialization starting …
terminate called after throwing an instance of ‘Aspect_GraphicDeviceDefinitionError’
Aborted
So, What am I doing wrong?
OK. Installing libgl1-mesa-swx11 solved the problem I was having. It works. The only question I have now is, what other applications did I break with this change? There were a number of packages removed, and I am not sure what dependencies may have been broken. Apparently, there is a conflict with libgl1-mesa-glx (and a couple of other obscure packages, mostly *-dev packages), and it is not clear what sort of dependencies I have broken…