Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python exception: ModuleNotFoundError: No module named 'stlib3' #65

Open
Fokion-Sanoudos opened this issue Feb 5, 2022 · 13 comments
Open

Comments

@Fokion-Sanoudos
Copy link

When trying to load a scene with stlib3.scene the above error shows up. The SOFA framework version is 21.12.00 and the plugin has been downloaded from GitHub and unzipped in the SOFA plugins directory. Is there something that I am missing?

@cdelor02
Copy link

I had a similar issue, a clear(er) solution may be found in my post to the SOFA discussions here. I assume you did the building step as described in the STLIB documentation? This creates many files in the build folder that you specify in the building process. Make sure you have the full path to the stlib3 site-packages directory (stlib3 because it is Python3!) in your PYTHONPATH environment variable on your computer. The site-packages directory can be found in your build directory, probably in the path C:\Users\Charlie\Documents\build\lib\python3\site-packages.

@Fokion-Sanoudos
Copy link
Author

But according to the newer SOFA version there shouldn't be a need for building the plugin. Just unzip it in the plugin folder of the SOFA directory and add it through the menu. At least that's what I understood.

@cdelor02
Copy link

That was my understanding as well, however I believe that is merely what SOFA requires, not Python3. Python still needs the necessary build/files in order to connect to the STLIB files in your SOFA directory. I did the out-of-tree-build for SOFA and STLIB, simply downloading the v21.12 SOFA binary. For STLIB, download the most recent update and unzip that into your plugins directory in SOFA (there was a recent update). Then complete the out-of-tree build steps as described in the STLIB README. The key directory site-packages that you need to use STLIB as a Python library with SOFA.

@ozilxu
Copy link

ozilxu commented Jun 3, 2022

I have already set the "site-package" in the Python path, but I still have "from stlib3.scene import MainHeader, ContactHeader
ModuleNotFoundError: No module named 'stlib3'". I am using the compiled version of sofa22 on Windows platform. May I ask if I should recompile the SOFA with STLIB? @cdelor02 @Fokion-Sanoudos @alxbilger Thanks!

@damienmarchal
Copy link
Member

damienmarchal commented Jun 3, 2022

Hi all,

The Sofa v21.12 version is shipped with SofaPython3 by default while the SoftRobots plugins was still based on SofaPython2. We updated everything for the robosoft workshop in april 2022. Our mistake that we didn't made that clear on our website.

My recommendations to have a working setup:

@ozilxu
Copy link

ozilxu commented Jun 3, 2022

@damienmarchal Thanks! I am using the version for the SoftRobot22 conference on Windows platform and python3.8. But I still got some import error of Stlib3. May I ask the new version at the end of June will fix this issue and enable to extract the stiffness matrix and cosserat rod modeling?

@damienmarchal
Copy link
Member

@ozilxu

About the matrices export I know that @alxbilger made pull request recently, sofa-framework/SofaPython3#262 .
Don't hesitate to have a look at it, provide feedback or review. But I don't know if it will be merged into master for the v22.06 release.

About the cosserat rod modelling, the best is to ask @younesssss if the plugin will be ready for that timeline.

@adagolodjo
Copy link
Contributor

Hey @ozilxu,

@damienmarchal Thanks! I am using the version for the SoftRobot22 conference on Windows platform and python3.8. But I still got some import error of Stlib3. May I ask the new version at the end of June will fix this issue and enable to extract the stiffness matrix and cosserat rod modeling?

What are the new errors?
Corsserat is already compiled with Python3, so no need to wait for the new version.
From my point of view, this link sent by @damienmarchal should work.

@ozilxu
Copy link

ozilxu commented Jun 3, 2022

@younesssss I am using this version with Windows platform and python3.8: https://github.com/SofaDefrost/RoboSoft2022/releases/tag/release-main). But I still got "ModuleNotFoundError: No module named 'stlib3'" error when using the tutorial of the Softrobots plugin. Even though I have already set the "site-package" in the Python path and in the system configuration.

@ozilxu
Copy link

ozilxu commented Jun 3, 2022

@younesssss Thanks again for your help! I have searched the directory of the plugin (The version with Windows platform and python3.8: https://github.com/SofaDefrost/RoboSoft2022/releases/tag/release-main) and I didn't find a cosserat plugin. Should I compile it with this repository (https://github.com/SofaDefrost/plugin.Cosserat) on my own with python3?

@alxbilger
Copy link
Member

Hello,

I also have the ModuleNotFoundError: No module named 'stlib3' problem.
I am under Windows, I compiled STLIB in-tree and I set PYTHONPATH to C:/Users/Alex/Dev/sofa2/builds/lib/python3/site-packages. All repositories are based on their master branch.

  • I don't see any reference to STLIB in builds/lib/python3/site-packages.
  • I don't see any reference to STLIB in builds\lib\RelWithDebInfo.
  • I don't see any reference to STLIB in builds\bin\RelWithDebInfo.
  • STLIB.dll can be found in builds\external_directories\plugins\STLIB\bin\RelWithDebInfo. I added it into the plugin manager, but it does not help.

@damienmarchal
Copy link
Member

damienmarchal commented Jun 13, 2022

On Linux it work as expected and the stlib3 python package is located at

#dmarchal@defrost-rtx:~/projects/DEFROST/dev/upstream/builds/release/lib/python3/site-packages$ ls
Sofa SofaRuntime  SofaTypes  splib  splib3  stlib3

EDIT1: With a filemanager can you search where cmake has put the stlib3 files (eg: scene.py, wrapper.py) ? I wonder if the packaging is fogetting the files or if they are located at some weird location.

EDIT2: A quick look into CMakeLists.txt show that

if(SofaPython3_FOUND)
    message("-- Found SofaPython3")
    SP3_add_python_package(
        SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python3/src/splib3
        TARGET_DIRECTORY splib3
    )
    SP3_add_python_package(
        SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python3/src/stlib3
        TARGET_DIRECTORY stlib3
    )
    set(SofaPythonAny_FOUND TRUE)
endif()

My next guess would be to look at the SP3_add_python_package

@damienmarchal
Copy link
Member

damienmarchal commented Jun 13, 2022

In the robosoft2022 binary version the STLIB is there:
/SOFA_robosoft2022_python-3.8_Windows/plugins/STLIB/lib/python3/site-packages/

Which actually makes sense but imply to add to PYTHONPATH every python based package unless loaded with a plugin registering extra path (what loading STLIB.dll was doing in the past).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants