sofa-framework / sofa

Real-time multi-physics simulation with an emphasis on medical simulation.
https://www.sofa-framework.org
GNU Lesser General Public License v2.1
871 stars 297 forks source link

sofa_env installation #4223

Open Gabriele111 opened 7 months ago

Gabriele111 commented 7 months ago

Hi everyone,

i'm trying to install sofa_env for sofa. i already downloaded it from git hub but when i try to install it (i tried dirrent location: in the same environment as sofa, in the sofa folder, in the bin folder, etc), it tells me that it doesn't find the sofa module with sofapython3. Actually sofapython3 is in sofa (i can see it in the plugin manager). it looks like a path problem, like it can't find sofa for some reason, maybe i'm trying to install it in the wrong place. Can someone help me please?? maybe @ScheiklP

thank you very much!!

alxbilger commented 7 months ago

Hi,

have you followed the instructions on the documentation page? https://sofapython3.readthedocs.io/en/latest/content/Installation.html#using-python3

Gabriele111 commented 7 months ago

hi @alxbilger, thank you for your quick reply. Yes i followed the documentation page

alxbilger commented 7 months ago

Can you make sure that you are able to open a Python scene within runSofa? Also verify again the values in SOFA_ROOT and PYTHONPATH.

ScheiklP commented 7 months ago

Hi @Gabriele111 , There is also a slightly more verbose guide on https://scheiklp.github.io/sofa_env/setting_up_sofa.html

Gabriele111 commented 7 months ago

i tried with liver.py and springForceField.py and it does work.

ScheiklP commented 7 months ago

Could you check that the library files were correctly linked to your env?

https://scheiklp.github.io/sofa_env/setting_up_sofa.html#manually-linking-sofapython3-to-python

Gabriele111 commented 7 months ago

i forgot to mention that i installed sofa from binary for ubuntu

ScheiklP commented 7 months ago

Ah, yes, then you can do the same as described here https://scheiklp.github.io/sofa_env/setting_up_sofa.html#manually-linking-sofapython3-to-python.

In the downloaded zip, the path is the same (plugins/SofaPython3/lib/python3/site-packages)

Gabriele111 commented 7 months ago

Hi @ScheiklP, thank you for your reply. I did as you said and now it seems to find sofa module and python. But it gives another error i can't solve, which happens when it tries to install gym and it says '..error in gym setup command: 'extras_require' must be a dictionary whose values are strings or lists of strings containing valid project/version requirement specifiers. '

ScheiklP commented 7 months ago

Hi @Gabriele111, How do you install gym? pip install gym==0.21.0?

Gabriele111 commented 7 months ago

I tried both with pip install gym==0.21.0 , with git clone and conda install

ScheiklP commented 7 months ago

Could you try downgrading setuptools and wheel? It sounds a bit like this problem here: https://stackoverflow.com/questions/76129688/why-is-pip-install-gym-failing-with-python-setup-py-egg-info-did-not-run-succ

Even though I am not quite sure, why it complains about extras_require, if you do not pass it at all. Maybe this can give more insights https://github.com/freqtrade/freqtrade/issues/8078

I am currently porting sofa_env to gymnasium, so that problem is only temporary.

Gabriele111 commented 7 months ago

i managed to solve it using 'conda install -c conda-forge gym==0.21.0'. But it tells me it needs python3.9 to work but i used python3.8. Does sofa need python3.8 to use python plugin or i can use python3.9 as well?

ScheiklP commented 7 months ago

Nice! The binaries that you can download from the website are built with python3.8, so they will also only work with python3.8. My best advice would be to build sofa from source with a python version of your choosing. I am currently using python3.10.

Gabriele111 commented 7 months ago

Ok thank you very much for your help!!

ScheiklP commented 7 months ago

You're very welcome. Let me know, if you need more help.

Gabriele111 commented 7 months ago

Hi @ScheiklP, sorry to bother you again. I am trying to install sofa from source so that i can use a =>3.9 version of python as you suggested. I'm facing some problems though. when i compile sofa with cmake i get this error 'Adding plugin SofaPython3 CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message): Could NOT find Python (missing: Python_LIBRARIES Python_INCLUDE_DIRS Development) (found suitable version "3.9.18", minimum required is "3.7") Call Stack (most recent call first): /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake-3.16/Modules/FindPython/Support.cmake:2214 (find_package_handle_standard_args) /usr/share/cmake-3.16/Modules/FindPython.cmake:304 (include) applications/plugins/SofaPython3/CMakeLists.txt:86 (find_package)'

ScheiklP commented 7 months ago

No worries. That sounds like a cmake problem. Could you try upgrading your cmake to at least 3.19? I am currently using 3.22.

Gabriele111 commented 7 months ago

i am using 3.26.4

ScheiklP commented 7 months ago

The error says you are using 3.16. CMake Error at /usr/share/cmake-3.16

Gabriele111 commented 7 months ago

you're right, but if i check cmake --version it tells it's 3.26.4. that's strange. Anyway i tried to uninstall and install it again but the version doesn't change

ScheiklP commented 7 months ago

Hmmmm, it's a bit hard debugging that remotely. Personally, I would try

Gabriele111 commented 7 months ago

Hi @ScheiklP, i have a doubt: i managed to configure sofa with cmake, when i add sofapython3 plugin from the camke-gui i don't get any errors but when i check the plug-in list (plugin_list.conf.default), sofapython3 is not there. is it normal?

thank you!

ScheiklP commented 7 months ago

Hi @Gabriele111 I do not have any experience with the cmake-gui. That's also why I did not include it in the sofa_env instructions on how to build SOFA. ;) https://github.com/ScheiklP/sofa_env_devel/blob/main/docs/source/setting_up_sofa.rst

Also the default plugin list is manually adapted AFTER compiling SOFA. https://github.com/ScheiklP/sofa_env_devel/blob/main/docs/source/setting_up_sofa.rst#:~:text=Add%20SofaPython3%20to%20the%20list%20of%20default%20plugins%20so%20that%20SOFA%20loads%20it%20by%20default.

Gabriele111 commented 6 months ago

Hi @ScheiklP, i built sofa from source using python 3.9.18. The problem is SofaPython3 plugin is not present in sofa when i run it and it's not in the plugin list either, even though, when building sofa, i don't get any errors.

Thank you for your help.

ScheiklP commented 6 months ago

Hi @Gabriele111,

When you say run sofa, do you mean running the runSofa binary, or importing it in python python3 -c "import Sofa" ?

Gabriele111 commented 6 months ago

I mean the runSofa.exe( i'm using windows right now) binary placed in the ../sofa/build/bin/Release directory

ScheiklP commented 6 months ago

Hi @Gabriele111, I have absolute no experience with SOFA on Windows. Maybe @hugtalbot knows who would be the best person to ask?

Gabriele111 commented 6 months ago

ok, thank you anyway. Have you ever faced a similar problem with ubutu?

ScheiklP commented 6 months ago

I am not sure what the actual problem is.

Gabriele111 commented 6 months ago

Basically, when i compile sofa using cmake it says that it is adding sofapython3 and it seems not to have any problems. But when i run runSofa.exe sofapython3 is not in the plugin list and i cannot open python scenes in sofa. I can't load it manually fromn the plugin manager either. I tried also to follow the guide to install python3 on github but the problem still remains.

Gabriele111 commented 6 months ago

i forgot to say that i fetched sofapython3 using the variable sofa_fetch_sofapython3 in cmake