Can't seem to get the OBS Python Library to work correctly. Help pls.

MudBocx

New Member
G'Day,

I've been scratching my head over a certain problem for a couple of days and I can't seem to figure it out myself. I'm trying to get the obspython.py to work.
I tried the following:
- different OS configurations on MacOS and Windows: failed
- different scripts referencing the obspython.py used by OBS: failed
- searched the forums and the web for a CLEAR instruction on how to get this working - sadly I found nothing useful

Software used: Win 10 64-bit, OBS 23 64-bit, Python 3.7.2 64-bit

ATM I copied the obspython file to my python install directory and wrote "import obspython as obs". It seems to recognize it but puts out multiple errors on the python shell and does nothing when loaded in OBS [I'm using the url-text.py from the sample folder].

I can't even get a function to print the current OBS version on the shell, which is embarassing.
The error seems to be the reference to the obspython file. I know this question is pretty trivial but could you guys give me some clear directions on what to do to reference the file correctly?

Python:
Traceback (most recent call last):
  File "C:\Program Files\Python 3.7.2\lib\obspython.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Program Files\Python 3.7.2\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named '_obspython'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\Python\testscript2.py", line 1, in <module>
    import obspython as obs
  File "C:\Program Files\Python 3.7.2\lib\obspython.py", line 17, in <module>
    _obspython = swig_import_helper()
  File "C:\Program Files\Python 3.7.2\lib\obspython.py", line 16, in swig_import_helper
    return importlib.import_module('_obspython')
  File "C:\Program Files\Python 3.7.2\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_obspython'
>>>
 
Last edited:

ZaneH

New Member
Made an account on the forum just to say same.

I thought this would be easier than writing the plugin in C...but I can't even import obspython.
 

ZaneH

New Member
I just switched to Lua (which OBS clearly prefers) and things are moving along.

B3RH5B0.png


edit: Two weeks later I migrated everything to C
 
Last edited:

MudBocx

New Member
You need to be using Python 3.6.x it does not work with newer python versions. I just tested this myself.
I'm pretty glad I found this thread again. Can't remember if this version speciality is noted in the documentation anywhere but it works with 3.6.
 

Lime Reversed

New Member
I'm having the same issue. I was going to try using 3.6, as this thread suggested, but then I saw it's no longer on pythons website and I realized this thread was from 2019/2020. Currently I'm using python 3.12 and my OBS script does work. The only problem is that Pycharm refuses to run tests on my code because "No module named obspython". So if the script is working in OBS I figure maybe I'm missing something else other than versions? If the problem however is the version, then what version of python should I be using in 2024?

1717882114992.png
 

Suslik V

Active Member
@Lime Reversed The version of Python depends on build of OBS and OS (some code changes wasn't included in official releases and added later, as mentioned in: https://obsproject.com/forum/thread...0-and-am-using-python-3-12.171588/post-632100).
Some related changes:

And try to find module manually, before attempting to import it. Is there any?
 
Top