RV python interpreter

I have a python script that’s working well when I test it from the ShotGrid Python Console within RV. But I would like to run the script externally. I thought that the python interpreter would do the trick (/Applications/RV.app/Contents/MacOS/py-interp) but it can’t import the rv.commands module:

import rv.commands as rvc

ModuleNotFoundError: No module named ‘rv.commands’

Any advice? Thanks!

You could use the -pyeval RV command line option to execute your script:

/Applications/RV.app/Contents/MacOS/RV -pyeval "from rv import commands;commands.addSourceVerbose(['syncflash,start=1,end=500,interval=1,fps=24.movieproc']) "

Alternatively you could also have your code executed as part of a python package in RV:
How do I write my first package in RV?

I hope this helps,

Bernie

1 Like

Hi Bernie. These are helpful suggestions that I can play around with. But ultimately I don’t think exactly what I’m looking for.

To give more context, the script I’m writing is a custom RV session build to be launched from ShotGrid. Select your versions, click a button, and then the script will build an RV session with the files stacked with old versions, plates, etc.

So it’s a long enough script that embedding it in a pyeval command seems odd. The package suggestion could work, but that would mean the user would click a button in ShotGrid that would prep an input file somewhere, then click a button in RV to actually ingest said input file. Two clicks ain’t the end of the world, but it doesn’t feel like the ideal design.

I guess I just figured I was missing a path to a true python interpreter that has all of RV’s modules included. It seems to me like this desire to access the rv.commands module to prep a session externally would be relatively common.

So, still looking for input if there are any suggestions. But in the meantime, will use one of the options that you suggested.

Thanks!

Use pyeval to import a python script and run it?
That would be a few lines only.

1 Like

You can also alter the rvlink:// uri handler btw.

1 Like