`from sqlalchemy import create_engine` import error

See original GitHub issue

Describe the bug Getting the following when importing 1.4.0 sqlalchemy’s create_engine method:

Python 2.7.5 (default, Aug  7 2019, 00:51:29)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sqlalchemy import create_engine
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/__init__.py", line 9, in <module>
    from .engine import create_engine
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/__init__.py", line 18, in <module>
    from . import events
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/events.py", line 9, in <module>
    from .base import Engine
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 12, in <module>
    from .interfaces import Connectable
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/interfaces.py", line 11, in <module>
    from ..sql.compiler import Compiled  # noqa
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/__init__.py", line 13, in <module>
    from .expression import Alias
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/expression.py", line 144, in <module>
    from .lambdas import lambda_stmt
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/lambdas.py", line 1067
    exec(code, vars_, vars_)
SyntaxError: unqualified exec is not allowed in function '_rewrite_code_obj' it contains a nested function with free variables

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:23 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
zzzeekcommented, Mar 23, 2021

glad we could figure this out thanks all for the help!

1reaction
dwtcommented, Mar 22, 2021

@zzzeek See #6112 for a pull request. I’m not sure though how to provide a meaningful test for this, without having a test executor that also runs python 2.7.5. Please advise what you need there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Circular Import Error while importing create_engine in ...
ImportError: cannot import name 'create_engine' from partially initialized module 'sqlalchemy ' (most likely due to a circular import).
Read more >
[Fixed] ModuleNotFoundError: No module named 'sqlalchemy'
Quick Fix: Python raises the ImportError: No module named 'sqlalchemy' when it cannot find the library sqlalchemy . The most frequent source of...
Read more >
Error Messages - SQLAlchemy 1.4 Documentation
Exception raised when the database encounters an internal error, e.g. the cursor is not valid anymore, the transaction is out of sync, etc....
Read more >
wrap sqlalchemy exceptions in a generic error - OpenDev
wrap sqlalchemy exceptions in a generic error ... -61,7 +61,6 @@ import sys. import time. import IPy. from sqlalchemy import exc.
Read more >
How to Fix : “ImportError: Cannot import name X” in Python?
You can solve the “ ImportError : Cannot import name X” Error by resolving the circular dependencies. You can do that either by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found