How to code a correct import statement to avoid the deprecation warning

Hi, I am a Python beginner. Im getting DeprecationWarning Using or importing the ABCs from ‘collections’ instead of collections.abc will stop working in Python 3.10

import pymssql as pymssql

5. The import system — Python 3.14.7 documentation is very technically correct it seems, but any combo of import, from I try gives me a syntax error.

My python version is 3.9.2 on a Raspberry Pi, armv7l GNU/Linux

python3 -m pip show pymssql says the package is in /usr/lib/python3/dist-packages

in that lib I see pymssql-2.1.4.egg-info and pymssql.cpython-39-arm-linux-gnueabihf.so

What should my import statement be please?

Post the complete exception traceback you’re seeing. Most likely, the problem isn’t actually in your code, it’s inside pymssql; it is unfortunately not uncommon for various packages to cause warnings, and you have to check the traceback to see exactly where the warning is coming from.

I do notice though that there is a newer version of pymssql available. I can’t install either it or the version you’re using as I don’t have the necessary prerequisites, but it may be worth considering. (Side note: If you look at the project’s GitHub, ignore the “Releases” section; it seems they haven’t made a GitHub release since 2020. However, this does appear to be where active development happens.) I tracked down a closed issue which refers to this exact warning, and it claims that the fix is in version 2.1.5, so your odds are good that upgrading (either to 2.1.x or all the way to 2.3) will fix the issue.

Wonderful, thanks Chris for your time and effort! I was convinced it was my problem, as its normally 99.9 percent truly my problem. OK I am going to try get the latest / working version of pymssql; my bypass until then will be to suppress the Deprecation warning, but I’ll make sure that the pymssql is the only warning being bypassed. You may have guessed, I’d prefer mysql with decent userbase/support, but… “the customer is always right” :wink: My code is a few 100 lines, working, so I won’t bore anyone or invite justified criticism. Thanks again!

That’s a good default :slight_smile: But as you learn to read tracebacks, you’ll get to know how to spot issues in libraries.

Oh, I’m not criticizing the choice to use MS SQL Server;[1] it’s just that, since I don’t have anything related to that, I can’t just quickly spin up a venv and try installing different versions to see whether they exhibit the same problem.

Happy to help!


  1. though personally, it’s PostgreSQL all the way! ↩︎