ModuleNotFoundError: No module named 'opensim'

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Jip Helsloot
Posts: 6
Joined: Wed May 03, 2023 1:49 am

ModuleNotFoundError: No module named 'opensim'

Post by Jip Helsloot » Wed May 03, 2023 2:35 am

I am totally new to OpenSim and Google colab and I am following "Getting started with analyzing OpenCap data using OpenSim API" in Google Colab.

When trying to install the OpenSim conda package using conda in Google Colab with the following code:
------------------------------------------------------------
import condacolab
condacolab.install()
!conda install -c opensim-org opensim=4.4=py39np120
------------------------------------------------------------

It gives the following output:

Downloading https://github.com/conda-forge/miniforg ... -x86_64.sh...
Installing...
Adjusting configuration...
Patching environment...
Done in 0:00:13
Restarting kernel...
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: |
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abortfailed

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

- opensim==4.4=py39np120 -> python=3.9
- opensim==4.4=py39np120 -> python[version='>=3.7,<3.8.0a0|>=3.8,<3.9.0a0|>=3.9,<3.10.0a0']

Your python: python=3.10

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

Then continuing to run the next part of the script:
---------------------------------------------------------------------------------------
!git clone https://github.com/stanfordnmbl/opencap-processing.git
%cd /content/opencap-processing
!python3 -m pip install -r requirements.txt
import os
import utilsKinematics
from utils import download_kinematics
from utilsPlotting import plot_dataframe
---------------------------------------------------------------------------------------

It gives me the following error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-47-d18cb6e9cdb7> in <cell line: 2>()
1 import os
----> 2 import utilsKinematics
3 from utils import download_kinematics
4 from utilsPlotting import plot_dataframe

/content/opencap-processing/utilsKinematics.py in <module>
20
21 import os
---> 22 import opensim
23 import numpy as np
24 import pandas as pd

ModuleNotFoundError: No module named 'opensim'

Is this due to the higher python version and if so, can i downgrade in the version? or something else like importing the utilsKinematics package?
I am looking forward to a respond.

Kind Regards,

Jip

User avatar
Mohammadreza Rezaie
Posts: 408
Joined: Fri Nov 24, 2017 12:48 am

Re: ModuleNotFoundError: No module named 'opensim'

Post by Mohammadreza Rezaie » Sun May 07, 2023 12:23 am

Hi, the issue is an incompatibility between the current Google Colab Python version (3.10) and the OpenSim conda distribution which only supports Python versions 3.7, 3.8, and 3.9.
https://anaconda.org/opensim-org/opensim/files

You may want to wait until the OpenSim developers release the py310 for Linux. However, there are some ways to change the Colab Python version or create a virtual environment with specific Python version, but they are not straightforward, e.g.:
https://stackoverflow.com/questions/686 ... on-version
https://colab.research.google.com/drive ... qY0q07qIzF

At this time, I suggest working with that on your local machine:
https://github.com/stanfordnmbl/opencap ... quirements

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

Re: ModuleNotFoundError: No module named 'opensim'

Post by Ayman Habib » Mon May 08, 2023 10:16 am

Thanks Mohammadreza,

The package for python 3.10 has been posted on anaconda.org so you shouldn't need to do any work arounds. Please let us know otherwise.

Best regards,
-Ayman

POST REPLY