Forums

Error importing SQLAlchemy

I am trying to deploy my first webapp with SQLite , I have configured the WGSI file and the virtualenv but whent trying to access my site I It returns error. The error.log comes with this message:

Error running WSGI application ImportError: cannot import name 'DeclarativeBase' from 'sqlalchemy.orm' (/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/init.py) File "/var/www/vinimoura_pythonanywhere_com_wsgi.py", line 16, in <module> from server import app as application # noqa

File "/home/vinimoura/mysite/server.py", line 9, in <module> from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column

My requirements.txt is like this>

Flask

Werkzeug

flask-bootstrap

flask-login

flask-wtf

WTForms

Pandas

socket

flask_sqlalchemy

but when I try to install it I have the problem:

ERROR: Could not find a version that satisfies the requirement Socket (from versions: none) ERROR: No matching distribution found for Socket

When I try to install without socket, it comes with the error:

ERROR: Could not find a version that satisfies the requirement flask_sqlalchemy
ERROR: No matching distribution found for flask_sqlalchemy

What could I do?

Looks like a version problem. Do you have pinned versions in your requirements.txt?

no, I haven't

That just means that there is no package on PyPI called "socket" so you cannot install it - because it does not exist.

socket is a standard builtin Python module. There can be no PyPI package of that name, it has no place in a requirements file.

Your flask-sqlalchemy has a typo, you've written it with an underscore. Don't confuse package names on PyPI with import statements that use them.

Thanks for clarifying