Search code examples
pythonsqlitetwitch

No module named _sqlite3 using python 2.7.13 from streamlabs chatbot


The problem

I am trying to add the sqlite module to my python script that uses 2.7.13 in the streamlabs chatbot app.

When I run my script from 2.7.13 idle it works no problem. However when I run it from the streamlabs chatbot it gives the error no module named _sqlite3.

The streamlabs chatbot allows you to select the directory of where your lib is which mine is set to. I checked the lib folder and it has an sqlite folder inside of it already. https://streamlabs.com/content-hub/post/chatbot-scripts-desktop

I assume that the module would need to be placed where the other scripts are which is C:\users\user folder\app data\roaming\streamlabs chatbot\services\scripts. For example, the boiler plate example made on git hub here:https://github.com/AnkhHeart/Streamlabs-Chatbot-Python-Boilerplate/tree/master/Boilerplate shows a lib folder in the specific script folder where he can import his custom module. Would have to do the same thing to make sqlite work in the streamlabs chatbot?

Here is the code:

import sys
import os
import time
import sqlite

ScriptName = "VLC Search and play"
Website = "twitch.tv/masterjx9"
Description = "VLC search and play app"
Creator = "masterjx9"
Version = "1.0.0"

settings = {}
searchRequest = ""
resetTime = 0

#more stuff

Here is the result in idle python:

>>>
#which is perfect

Here is the result in streamlabs chatbot:

no module named _sqlite3

Any ideas or suggestions would be awesome. Thank you


Solution

  • I was able to find my own answer thanks to the Streamlabs chatbot discord channel.

    Streamlabs uses ironpython instead of python and they handle somethings different. They were able to give me an example of a script that uses a sqlite db and the major difference is that you need the following in order for sqlite3 to be imported:

    import clr
    clr.AddReference("IronPython.SQLite.dll")
    clr.AddReference("IronPython.Modules.dll")
    
    #Now you can import SQLite as shown in the line below
    
    import sqlite3
    #no errors in the chat bot
    

    Hope this helps for anyone else.