Use Pysbs in different python interpreter (maya, sd, blender...)


Depending on the software and its interpreter it may not be possible to use pip to install Pysbs like it's presented in Getting started.

If so, the best way is to extract the pysbs.zip archive (the one which is used by pip) in an appropriate location and add this location to the PYTHONPATH environment variable.

Linux : export PYTHONPATH=/location/of/my/pysbs_parent_directory:$PYTHONPATH

Windows : set PYTHONPATH=C:\location\of\my\pysbs_parent_directory;%PYTHONPATH%

As an instance, it's possible to make it permanently to add this line in the ~/.bashrc or on Windows with "set variable system" parameters.

Another approach less elegant is to add the location at the very beginning of your script with sys module, i.e:

import sys

sys.path.append("/location/of/my/pysbs_parent_directory")

from pysbs import context

Maya case and its Maya.env file:

A way to use pysbs in maya without set the PYTHONPATH variable, permanently or with a "pre-run" script, is to use these following steps:

  • Manually unzip the python package in a location of your choice.
  • Edit Maya.env (see here) adding the directory to the PYTHONPATH environment variable.
    Note that the path should be the path to the directory in which the pysbs directory is located
    The line would look something like this:

Windows: PYTHONPATH=C:\work\Pysbs-2017.2.0;%PYTHONPATH%

Linux: PYTHONPATH=/work/Pysbs-2017.2.0:$PYTHONPATH

  • Start maya. In order to verify that the installation is successful, open a python script editor and enter

from pysbs import sbsenum

  • If you don't get an error the installation is a success and you can start using pysbs functions from inside of Maya

In order to use pysbs from mayapy you need to follow the steps above. Before calling any functions you also need to run the lines below to make sure Maya.env is loaded.

import maya.standalone 
maya.standalone.initialize(name='python')