'ImportError: cannot import name 'URL' from 'sqlalchemy.engine'

Why I cannot make sqlalchemy.engine working correctly?

I have installed SQLAlchemy

 pip install SQLAlchemy

I have following code in Python

 from sqlalchemy.engine import URL

It cause error:

ImportError: cannot import name 'URL' from 'sqlalchemy.engine' (C:\Python\Python3.8.9\lib\site- 
packages\sqlalchemy\engine\__init__.py)


Solution 1:[1]

Try to install it with this command:

pip3 install flask-sqlalchemy

If it doesnt worked then try above commands with --user at the end of both commands.

pip3 install flask-sqlalchemy --user

Solution 2:[2]

This is because of the SQLAlchemy version. Please install the latest version

pip3 install snowflake-sqlalchemy==1.4.32

and it will work fine.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alejandro Martinez
Solution 2 Yididya