Python Forum

Full Version: pymssql module not found
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm new here and it's my first post, that's why don't judge too harshly.

I am traying to make web page on Raspberry pi 4B using Flask framework. When i tryed import pymssql I get error 'ModuleNotFoundError: No module named 'pymssql'', but pymssql module is installed on my Raspberry pi.

Maybe someone can get some ideas why it so and how to fix it?
the python version that is active at time of script execution must be in sync with the pip version.
To verify that this is the case, check versions of both:
use python -V and pip -V
you should see something like:
Output:
(venv) $ python -V Python 3.10.4 (venv) $ pip -V pip 22.1.1 from .../venv/lib/python3.10/site-packages/pip (python 3.10)
as you can see version in both cases is 3.10
Thank for replay.
I tried check versions and both have 3.9, but still on FLASK pymssql module not recognised.
and pip list shows pymssql?
Also, show exact unaltered error traceback
pymssql is on pip list.

When I check if pymssql is installed its good, but when I try to run web server I get error:

im@raspberrypi:~/Desktop/Studiju darbs/Majas_Lapa $ python
Python 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymssql
>>>
[2]+ Stopped python
im@raspberrypi:~/Desktop/Studiju darbs/Majas_Lapa $ sudo python main.py
Traceback (most recent call last):
File "/home/im/Desktop/Studiju darbs/Majas_Lapa/main.py", line 1, in <module>
from website import create_app
File "/home/im/Desktop/Studiju darbs/Majas_Lapa/website/__init__.py", line 2, in <module>
import pymssql
ModuleNotFoundError: No module named 'pymssql'



Here will be my main.py:

from website import create_app

app = create_app()

if __name__ == '__main__':
app.run(host="0.0.0.0",port=80,debug=True)

Here will be my __init__.py:

from flask import Flask
import pymssql

def create_app():
app = Flask(__name__)
app.config['SECRET_KEY'] = 'QSJSNDFSDKFSKDFSD SKSDLdsfsdf'

from.views import views
from.auth import auth

app.register_blueprint(views, url_prfix='/')
app.register_blueprint(auth, url_prfix='/')

return app



I tried instead of pymssql use pyodbc, sqlalchemy and flask_sqlalchemy and get the same error when try to run web server on Raspberry pi
installed and tried on my system (linux mint 20.2)
imported without a hitch:
Output:
Python 3.10.4 (main, Apr 1 2022, 08:36:25) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pymssql >>> quit()
don't know what to say.