Sublime Forum

How to import pyodbc in sublime plugin development


Hi folks,
I am a newbie in sublime plugin development.
I am trying to develop a teradata sql tool plugin by leveraging pyodbc, stuff like this and then parse the sql result in sublime window

import pyodbc 
conn = pyodbc.connect(driver,DBCName, database, uid,pwd)
cursor = conn.cursor()
cursor.execute("select * from table")

After pip install pyodbc, I can run import pyodbc in cmd environment with no problem.

Since where pyodbc installed is in sys.path and python recognize that location

However, in “sublime python” (the python cmd after type ctrl+`), even though I install here

and this path is in sys.path, I still can’t import pyodbc.

I also try to create a dummy python file called test38 here

and in above screenshot, we can see can be imported.

So does pyodbc with .pyd file extension can’t be import in sublime plugin development or do I miss something here?

Thank y’all so much for the help! :joy:


  1. You downloaded a wrong wheel. pyodbc-4.0.34-cp38-cp38-win_amd64.whl should be used.
  2. Put pyodbc.cp38-win_amd64.pyd under Lib\python38.
  3. Maybe restart ST.


yep that works perfectly! thank you!



That works!
And may I also ask how to set up a build point to 3.8 in sublime text 4? Currently it will automatically build with 3.3.



Build? It just calls py on your machine.

You have to create your own build system if that’s not what you want.



A .python-version with a content of 3.8 placed in a package’s root directory tells ST to run a plugin with python 3.8 plugin host.