Page 1 of 1

Python 3.11 and OpenSim 3.3 Integration Issues

Posted: Tue Oct 22, 2024 2:51 pm
by waltmenke
Hi everyone,

I've been trying to get Python 3.11 to integrate with OpenSim 3.3 (on Windows 11) so I can run a bunch of Static Optimizations and Joint Reaction Analyses. Doing that seems to be the easy part, and actually getting the package imported seems to be the real struggle. I've been heavily using the Scripting in Python help page (https://opensimconfluence.atlassian.net ... +in+Python).

I have added the environment variables, and I'm in the C:\OpenSim 3.3\sdk\Python directory when I run the setup.py file. Once that script runs, it does print out version 3.3 in the command window for me, but when I do my "import opensim as osim" and "osim.GetVersionAndDate()" it gives me the AttributeError that the opensim module does not have GetVersionAndDate. I've looked through the 3 troubleshooting tips, and none of them apply to me (as far as I'm aware).

Am I missing something pretty obvious here? Thanks for any help and assistance.

Re: Python 3.11 and OpenSim 3.3 Integration Issues

Posted: Tue Oct 22, 2024 3:19 pm
by aymanh
Hi Walter,

Thanks for reporting. Can you explain how you're getting the OpenSim python bindings? Basically before version 4.0 we used to build in-house bindings with a fixed version of python. Considering that OpenSim 3.3 was released in 2015 and used the python version available then, it's not surprising that changes in python itself and/or in the runtime that was linked with OpenSim would cause breakage.

We highly recommend that you upgrade to version 4.5+ and to use the conda packages that we provide from the page below which enable a one line install (python 3.9-3.11 are available)
https://anaconda.org/opensim-org/opensim

Hope this helps,
-Ayman

Re: Python 3.11 and OpenSim 3.3 Integration Issues

Posted: Wed Oct 23, 2024 7:23 am
by waltmenke
Hi Dr. Habib,

Thanks for your reply! I'm using the powershell in VS Code to run the setup.py as recommended in the help documentation for dealing with OpenSim 4.2 or earlier. It does indeed process the dependencies for OpenSim 3.3 as printed out after running that file. But, after the import statement for the opensim package, it doesn't recognize any classes or methods (as in, GetVersionAndDate()). I also see the opensim.py script in the opensim folder of C:\OpenSim 3.3\sdk\Python which has the classes and methods, etc.

The only reason for using the older version here is that I'm using the Lerner et al. 2015 model to deal with medial and lateral contact forces at the knee. To my current knowledge, that model doesn't play well with the modern versions of OpenSim or I would simply move up to there.

I completely understand the deprecation of support for such an old version, so if that's the case (since it looks like Python was around v2.7 at the time), then I'll manage to find a workaround some other way. I appreciate your time and help! Thanks.

Re: Python 3.11 and OpenSim 3.3 Integration Issues

Posted: Thu Oct 24, 2024 5:13 pm
by waltmenke
UPDATE:

I've managed to get this to work between OpenSim 3.3 and Matlab 2023a using parts of the BOPS 2.0 package (https://simtk.org/projects/bops). This seems like it will be the way to go if you're using a considerably older version of OpenSim!