Python Scripting in Linux 7

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Stephanie Hachem
Posts: 34
Joined: Wed Oct 26, 2016 12:40 pm

Python Scripting in Linux 7

Post by Stephanie Hachem » Thu Jul 19, 2018 4:47 pm

Hello all,

I'm attempting to install OpenSim 3.3, in order to use it with Python (2.7 or 3.6), on a Red Hat Enterprise Linux (7) operating system, with the terminal. That Linux OS already has Python (Anaconda), python-setuptools, wheel, pip, simbody, and cmake installed. However, upon following OpenSim instructions for building OpenSim from source (as is necessary for Linux) with Python wrapping, the OpenSim installation folder doesn't contain a <OPENSIM_HOME>/lib/python2.7/site-packages/ folder, or a <OPENSIM_HOME>/lib folder. That folder is used in the instructions for setting up OpenSim Linux Python scripting <https://simtk-confluence.stanford.edu/d ... hon-Ubuntu>.

However, I set up OpenSim Python scripting previously on another operating system, and remembered that the command

Code: Select all

 python setup.py install 
in a directory containing /opensim_3.3-py3.6.egg and setup.py was necessary. I could find a Python-related folder in 3 places (see screenshot 3openSimPythonRelated.png) produced during building OpenSim in Linux; of these, 1 contained a setup.py file. I could find the .egg folder in /root/home/USERNAME/anaconda3/lib/python3.6/site-packages/opensim-3.3-py3.6.egg/ from a previous attempt to install OpenSim Python scripting on the same computer. So, I copied that .egg file to the folder containing the setup.py file and ran

Code: Select all

 python setup.py install 
That threw the error in the screenshot setupPyInstall.png.
In other words, I don't know how to proceed from here in installing OpenSim Python scripting in Linux 7. What did I do wrong, and what should I do?

My specific process:
Building OpenSim from source for Linux following instructions <https://simtk-confluence.stanford.edu/d ... ux+Support>

<https://simtk.org/frs/?group_id=91> Opensim Source code > Download package
unzip package in /root/Downloads
unzip 2 things in package in /root/Downloads

Code: Select all

 
mkdir /root/Documents/build 

# install cmake and ccmake
yum search cmake
yum install cmake.x86_64

# install simbody (with conda installed)
conda install -c conda-forge simbody

cd /root/Documents/build
ccmake ~/Downloads/OpenSim33-source/
Configured
In the GUI,
I set
BUILD_PYTHON_WRAPPING:BOOL=ON

Left alone:
BUILD_BINARY_DIR=/root/Documents/build
Simbody_HOME=
Simbody_DIR=/root/home/USERNAME/anaconda3/lib/cmake/simbody
Simbody_LIBRARIES=/root/home/USERNAME/anaconda/lib/libSimTKsimbody.so;/root/home/USERNAME/anaconda3/lib/libSimTKmath.so;/root/home/USERNAME/anaconda3/lib/libSimTKcommon.so;/root/USERNAME/anaconda3/lib/libopenblas.so;pthread;rt;dl;m
Simbody_STATIC_LIBRARIES=Simbody_STATIC_LIBRARIES-NOTFOUND

Configured, doesn't throw error
Generated, doesn't throw error

Code: Select all

# in /root/Documents/build
make # doesn't throw error
make test # doesn't throw error
make install # doesn't throw error
Set up OpenSim python following <https://simtk-confluence.stanford.edu/d ... +in+Python>

Code: Select all

# ensure I have python-setuptools 
python
>> import setuptools # doesn't throw error
>> exit()

# runs into error described in first paragraphs of post
Additional information:

Code: Select all

 
python
>> import opensim
>> m = opensim.Model()
see screenshot pythonImportOpenSim.png

3 OpenSim python-related places = see screenshot 3openSimPythonRelated.png; the first command was

Code: Select all

 ls 
in /.bashrc

Code: Select all

export OPENSIM_HOME=/root/Documents/build/OpenSim
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OPENSIM_HOME
PYTHONPATH=$PYTHONPATH:/root/Documents/build/OpenSim/Wrapping/Python
in terminal

Code: Select all

which python
	/root/home/USERNAME/anaconda3/bin/python
python --version
	Python 3.6.3 :: Anaconda custom (64-bit)
echo $PATH
/root/home/USERNAME/anaconda3/bin:/root/home/USERNAME/anaconda3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/root/bin
echo $PYTHONPATH
	/root/Documents/build/OpenSim/Wrapping/Python
Attachments
setupPyInstall.PNG
setupPyInstall.PNG (33 KiB) Viewed 483 times
pythonImportOpenSim.PNG
pythonImportOpenSim.PNG (26.36 KiB) Viewed 483 times
3openSimPythonRelated.PNG
3openSimPythonRelated.PNG (110.86 KiB) Viewed 483 times

Tags:

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Python Scripting in Linux 7

Post by Dimitar Stanev » Fri Jul 20, 2018 4:02 am

I suggest that you use the new OpenSim version from github as there may be bugs in the python wrappings. I have successfully installed the python wrappings for https://github.com/opensim-org/opensim-core on Linux.

User avatar
Stephanie Hachem
Posts: 34
Joined: Wed Oct 26, 2016 12:40 pm

Re: Python Scripting in Linux 7

Post by Stephanie Hachem » Fri Jul 20, 2018 5:15 pm

Hi Mr. Stanev,

What version of Linux and what version (<https://github.com/opensim-org/opensim-core>, <https://github.com/opensim-org/opensim- ... 4.0.0_beta>, <https://github.com/opensim-org/opensim- ... .0.0_alpha>, so forth > Clone or Download > Download ZIP) did you use? I've been trying a lot of things, to no avail.

Stephanie Hachem

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Python Scripting in Linux 7

Post by Dimitar Stanev » Mon Jul 23, 2018 12:30 am

Hi,

You can try the beta version, I have my own fork of OpenSim. I have built OpenSim successfully on archlinux, ubuntu and other distribtuins. The process is the same for any distribution.

1. Install simbody dependencies: https://github.com/simbody/simbody
2. Perform superbuild on opensim-core/dependencies (CMake)
3. Configure opensim-core/ providing the install dir of the opensim-core/dependencies and any other dir that is not automatically located by CMake
4. Build and install (I prefer ~/something)
5. Configure path variables (e.g. in .bashrc)

example:

Code: Select all

# simbody
export SIMBODY_HOME=~/dev/opensim-core/install/rwdi/dependencies/simbody
export Simbody_DIR=$SIMBODY_HOME/lib64/cmake/simbody
export PATH=$PATH/libexec/simbody:$PATH
export LD_LIBRARY_PATH=$SIMBODY_DIR/lib64:$LD_LIBRARY_PATH
# opensim-core
export OPENSIM_HOME=~/dev/opensim-core/install/rwdi/
export OpenSim_DIR=$OPENSIM_HOME/lib64/cmake/OpenSim
export LD_LIBRARY_PATH=$OPENSIM_HOME/lib64:$LD_LIBRARY_PATH
Note that the path variables are present only when you work in a terminal.

POST REPLY