Home › Forum › SOFA › Building SOFA › Error when loading SofaPython plugin
Tagged: softrobots
- This topic has 11 replies, 5 voices, and was last updated 5 years, 3 months ago by JImbles.
-
AuthorPosts
-
9 June 2019 at 10:00 #13612nickljBlocked
Recently I’ve downloaded the master branch of sofa (last commit on June 6) and compiled it. The reason I use the master branch is it seems v18.12 does not support CMake macros such as “sofa_install_pythonscripts” which is required by the master branch of STLIB and SoftRobots plugins.
The cmake options I used is as:
cmake ../ -DCMAKE_INSTALL_PREFIX=/home/liuj/opt/SOFA/master -DPLUGIN_SOFAPYTHON=ONHowever, although it can compiled and installed, it seems the SofaPython plugins cannot be loaded successfully when running ./runSofa. Because of this, I cannot run .py script in sofa. (.scn can be loaded and run successfully)
Much appreciate if anyone may help me to solve this out.
9 June 2019 at 10:03 #13613nickljBlockedI have already installed python2.7/numpy/scipy on my Ubuntu18.04 (gcc7.3) through apt
Actually exactly the same problem also occurs on my MacOS, with python installed through brew.The log file after running ./runSofa is attached as follows:
[INFO] [runSofa] PluginRepository paths = /home/liuj/opt/SOFA/master/plugins:/home/liuj/opt/SOFA/master/lib [INFO] [runSofa] DataRepository paths = /home/liuj/opt/SOFA/master/share/sofa:/home/liuj/opt/SOFA/master/share/sofa/examples [INFO] [runSofa] GuiDataRepository paths = /home/liuj/opt/SOFA/master/share/sofa/gui/runSofa:/home/liuj/opt/SOFA/master/share/sofa/gui/qt Created directory: /home/liuj/opt/SOFA/master/config Created directory: /home/liuj/opt/SOFA/master/screenshots [INFO] [runSofa] Loading automatically plugin list in /home/liuj/opt/SOFA/master/lib/plugin_list.conf.default [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/lib/libSofaExporter.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/lib/libSofaSparseSolver.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/lib/libSofaPreconditioner.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/lib/libSofaHaptics.so Traceback (most recent call last): File “<string>”, line 1, in <module> ImportError: No module named SofaPython.livecoding Traceback (most recent call last): File “<string>”, line 1, in <module> ImportError: No module named SofaPython [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/plugins/SofaPython/lib/libSofaPython.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/plugins/CImgPlugin/lib/libCImgPlugin.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/plugins/SofaMiscCollision/lib/libSofaMiscCollision.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/lib/libSofaAllCommonComponents.so [INFO] [GUIManager] INFO(SofaGUI): lastUsedGUI.ini not found; using default GUI. The constructor with a QGLFormat is deprecated, use the regular contructor instead. Traceback (most recent call last): File “<string>”, line 1, in <module> NameError: name ‘SofaPython’ is not defined [INFO] [SceneCheckerVisitor] Validating node “root” with checks: [SceneCheckAPIChange, SceneCheckDuplicatedName, SceneCheckMissingRequiredPlugin, SceneCheckUsingAlias] [INFO] [SceneCheckAPIChange] No ‘APIVersion’ component in scene. Using the default APIVersion level: 17.06 [INFO] [SceneCheckerVisitor] Finished validating node “root”.
10 June 2019 at 04:43 #13617nickljBlockedI’ve already solved this problem by modify some PYTHONPATH environment. It works very nice.
Now my problem is about the SoftRobots and STLIB plugin. When I run the SoftRobots tutorial (such as CableGripper), there is always errors showing that “TypeError: ‘staticmethod’ object is not callable”.
The detailed log file related to this error is as follows:
[INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/plugins/SoftRobots/lib/libSoftRobots.so [ERROR] [PythonScript] TypeError: ‘staticmethod’ object is not callable File “cablegripper.pyscn”, line 11, in createScene Gripper(rootNode) File “gripper.py”, line 14, in Gripper pullPointLocation=[3, 10.5, 3]) File “finger.py”, line 39, in Finger translation=translation) File “/home/liuj/opt/SOFA/master/plugins/STLIB/python/splib/objectmodel/__init__.py”, line 47, in __call__ o = self.cls(*args, **kwargs) File “/home/liuj/opt/SOFA/master/plugins/STLIB/python/stlib/physics/deformable/elasticmaterialobject.py”, line 30, in __init__ collisionMesh, withConstrain, surfaceColor, poissonRatio, youngModulus, totalMass, solver)
11 June 2019 at 19:03 #13628HugoKeymasterHi @nicklj
Thank you for your report regarding the SoftRobot project! It’s nice to see it so active!
I unfortunately do not know it very well.Please let me poke the experts: @damien-marchaluniv-lille1-fr and @bmarques
Best
Hugo
11 June 2019 at 22:00 #13632Damien MarchalBlockedHello,
I’m glad to hear about people trying the SoftRobot plugins.
My first advice is that if you don’t need to compile your self the plugin we are now providing binary version of Sofa+SoftRobot+SoftRobots.Inverse+STLIB. They are available at: https://project.inria.fr/softrobot/install-get-started-2/download/But if these version are not recent or complete enough for your needs and you require to compile everything yourself it seems to me that the problem is somewhere in the build process.
With Sofa there is two build process for plugins, one is “in-tree” and the other is “out-of -tree”. The in-tree build requires you to compile the plugin at the same time as Sofa, for that you need to register the plugin in the Sofa’s cmake configuration.
The other, the ‘out-of-tree’, allows you to compile Sofa (or take a compiled version of it) and apply cmake to the plugin only. For this process to work you need to specify where Sofa is.
I’m not sure but it seems to me you are using an out-of-tree build (can you confirm ?). Out of tree are a rather new way to handle compilation and there may still have bug.
In all cases you should see the following when starting Sofa:
[INFO] [SofaPython] Added '/home/dmarchal/projects/DEFROST/dev/sofa3/src/applications/plugins/SofaTest/python' to sys.path [INFO] [SofaPython] Added '/home/dmarchal/projects/DEFROST/dev/sofa3/plugins/STLIB/python' to sys.path [INFO] [SofaPython] Added '/home/dmarchal/projects/DEFROST/dev/sofa3/src/applications/plugins/SofaPython/python' to sys.path [INFO] [PluginManager] Loaded plugin: /home/dmarchal/projects/DEFROST/dev/sofa3/builds/release/lib/libSofaPython.so
The important lines is the registration of the python path by the different plugins. In your case this is was is missing in the reports you are making. But it is unclear to me why they are missing.
12 June 2019 at 08:37 #13635nickljBlockedHi, @damien-marchaluniv-lille1-fr
Thanks a lot for your reply. Firstly, I’ve downloaded the binary version and it works greatly. So anyway I’m now able to work on it.However, I still would like to figure out the reason why I’m not able to compile myself and get it work. As SOFA and SoftRobots are both in active development, and I would like to follow the state-of-art of these great work.
Come to my problem. Much apologize that I did not make it clear. The 1 and 2 floor in this topic are the problem I met when loading the SofaPython. After that, I rebuild the whole project together with SoftRobots and STLIB plugins. So it is actually an ‘in-tree’ build. Here I would like to re-explain my problem (Should I open a new thread specifically on this problem?)
Currently I’m trying to build the SoftRobots and STLIB plugins together with sofa platform (master branch). The cmake options I used is:
cmake ../ -DCMAKE_INSTALL_PREFIX=/home/liuj/opt/SOFA/master -DPLUGIN_SOFAPYTHON=ON -DSOFA_BUILD_METIS=ON -DSOFA_EXTERNAL_DIRECTORIES="/home/liuj/github/sofa/master/plugins/STLIB;/home/liuj/github/sofa/master/plugins/SoftRobots"
After successfully compiling and installing, I met some errors on
ImportError: No module named SofaPython
as I already mentioned above. I’ve found a workaround to solve this problem by setting
plugins/SofaPython/lib/python2.7/site-packages plugins/STLIB/python plugins/SoftRobots/lib/python2.7/site-packages
to the $PYTHONPATH environment.
Then, I can run ./runSofa successfully. However, when I try to run the examples in the SoftRobots plugins, I met some problems as:
[INFO] [runSofa] PluginRepository paths = /home/liuj/opt/SOFA/master/plugins:/home/liuj/opt/SOFA/master/lib [INFO] [runSofa] DataRepository paths = /home/liuj/opt/SOFA/master/share/sofa:/home/liuj/opt/SOFA/master/share/sofa/examples [INFO] [runSofa] GuiDataRepository paths = /home/liuj/opt/SOFA/master/share/sofa/gui/runSofa:/home/liuj/opt/SOFA/master/share/sofa/gui/qt [INFO] [runSofa] Loading automatically plugin list in /home/liuj/opt/SOFA/master/lib/plugin_list.conf.default [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/lib/libSofaExporter.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/lib/libSofaSparseSolver.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/lib/libSofaPreconditioner.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/lib/libSofaHaptics.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/plugins/SofaPython/lib/libSofaPython.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/plugins/CImgPlugin/lib/libCImgPlugin.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/plugins/SofaMiscCollision/lib/libSofaMiscCollision.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/plugins/MultiThreading/lib/libMultiThreading.so [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/lib/libSofaAllCommonComponents.so The constructor with a QGLFormat is deprecated, use the regular contructor instead. [INFO] [SofaPython] Added '/home/liuj/opt/SOFA/master/plugins/STLIB/python' to sys.path [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/plugins/STLIB/lib/libSTLIB.so [INFO] [SofaPython] Added '/home/liuj/opt/SOFA/master/plugins/SoftRobots/lib/python2.7/site-packages' to sys.path [INFO] [PluginManager] Loaded plugin: /home/liuj/opt/SOFA/master/plugins/SoftRobots/lib/libSoftRobots.so [ERROR] [PythonScript] TypeError: 'staticmethod' object is not callable File "cablegripper_banana.pyscn", line 19, in createScene Gripper(rootNode) File "gripper.py", line 14, in Gripper pullPointLocation=[3, 10.5, 3]) File "finger.py", line 39, in Finger translation=translation) File "/home/liuj/opt/SOFA/master/plugins/STLIB/python/splib/objectmodel/__init__.py", line 47, in __call__ o = self.cls(*args, **kwargs) File "/home/liuj/opt/SOFA/master/plugins/STLIB/python/stlib/physics/deformable/elasticmaterialobject.py", line 30, in __init__ collisionMesh, withConstrain, surfaceColor, poissonRatio, youngModulus, totalMass, solver) [INFO] [SceneCheckerVisitor] Validating node "root" with checks: [SceneCheckAPIChange, SceneCheckDuplicatedName, SceneCheckMissingRequiredPlugin, SceneCheckUsingAlias] [INFO] [SceneCheckAPIChange] No 'APIVersion' component in scene. Using the default APIVersion level: 17.06 [INFO] [SceneCheckerVisitor] Finished validating node "root". [WARNING] [RealGUI] Global Bounding Box seems very small; Your viewer settings (based on the bbox) are likely invalid, switching to default value of [-1,-1,-1,1,1,1].This is caused by using component which does not implement properly the updateBBox function.You can remove this warning by manually forcing a value in the parameter bbox="minX minY minZ maxX maxY maxZ" in your root node
It seems something related to static method. I’m not an expert of python. Much appreciate if you could help me on this.
2 July 2019 at 10:00 #13882Damien MarchalBlockedHi @nicklj,
Sorry to reply late.
My first guess with the failure to import SofaPython is that it may be because you specify the -DCMAKE_INSTALL_PREFIX=/home/liuj/opt/SOFA/master. I’m not sure to understand why you are specifying it. But this is supposed to be the location where sofa is installed and not the path to the source code.
The need for the workaround by setting manually the python path indicates somethings goes wrong at this step.
Now about the failure in STLIB. This is interesting and many thanks for the report.
This correspond to the lines:
@staticmethod
def createPrefab(self,…
Which up to my knowledge is fully valid python code. I will try to reproduce the lines you gave to see what happens on my system.EDIT: I opened an issue for that in https://github.com/SofaDefrost/STLIB/issues/29
2 July 2019 at 10:46 #13884nickljBlockedHi, @damien-marchaluniv-lille1-fr
Thank for very much your reply. I’ve commented in the issue.
Actually there is another problem I met for using the latest version, but it’s not relevant to this topic and I’ll create a new one.
12 July 2019 at 12:03 #13943GuillaumeKeymasterHello @nicklj,
Let me try to connect all the pieces together…
Your environment is:
– SOFA source dir =/home/liuj/github/sofa/master
– plugins source dir =/home/liuj/github/sofa/master/plugins
– SOFA build dir =/home/liuj/github/sofa/master/build
– SOFA install dir =/home/liuj/opt/SOFA/master
You have 2 problems:
1. SofaPython does not init sys.path correctly
2. You get a “‘staticmethod’ object is not callable” error when running a SoftRobots exampleAbout problem 1:
I recently added this commit that may solve your issue. Could you try updating your SOFA and test again (don’t forget to empty your PYTHONPATH before)?About problem 2:
What is the scene you are running?
@damien-marchaluniv-lille1-fr did you have the time to inspect the error?Hope that helps,
Guillaume.12 July 2019 at 17:42 #13944JImblesBlockedHey all,
I am also getting this same error! I am running on a fresh Ubuntu 18.04 VM. The binary version works fine for me, but I would like to be able to build it to both understand the software better, and to use the CGAL plugin in the future.
I have created a gist of all of the steps I have taken so far here. I used the CMAKE GUI to set it up.
When opening RunSofa I get a warning about python not being found in build dir, and when I try and run a softrobots pyscn like the cable gripper tutorial, I get the same error that
staticmethod
isnt callable.
I am guessing that this error is because python hasnt been loaded properly.My directories are
SOFA source
/home/james/sofa/master/src
SOFA build/home/james/sofa/build
STLIB/home/james/STLIB
SoftRobots/home/james/SoftRobots
A possibly related problem is that the SoftRobots docs and tutorials dont seem to be anywhere in the build directory, where as the build instructions imply they should be located in
/build/applications/plugins/SoftRobots
Thanks for any help you can offer!
15 July 2019 at 07:21 #13952nickljBlocked@guillaumeparan. Thanks a lot for your kind explanation.
For problem 1, the problem is already solved without SoftRobots and STLIB plugins. However, if I tried to run the examples required SoftRobots/STLIB plugins from the SOFA install dir, the same error occurs (but if I run in the SOFA build dir, it will be fine)For problem 2, sorry that it still exists. Previously I though it has been solved by running in the SOFA build dir, but I’ve tried again and it seems the problem still exists no matter in build dir or install dir.
Actually, after some search on the internet on this “staticmethod” problem, if I changed the file elasticmaterialobject.py line 28,
from “ElasticMaterialObject” to “self.__class__.”, the problem has gone, but I’m not an expert of Python and not sure whether this will influence other places….22 July 2019 at 13:34 #13974JImblesBlocked@guillaumeparan regarding the potential fix to problem 1, I am using commit 16225 which includes the potential fix you suggested. Sadly the problem persists.
-
AuthorPosts
- You must be logged in to reply to this topic.