aexile
aexile

Reputation: 31

ImportError: cannot import name inspect OpenShift

Trying to deploy my application on OpenShift I'm stuck with this error:

Traceback (most recent call last):
  File "app.py", line 35, in <module>
    application = imp.load_source('app', 'flaskapp.py')
  File "flaskapp.py", line 2, in <module>
    from flask_sqlalchemy import SQLAlchemy
  File "/var/lib/openshift/56ad93df7628e163fa00003a/python/virtenv/lib/python2.7/site-packages/
Flask_SQLAlchemy-2.1-py2.7.egg/flask_sqlalchemy/__init__.py", line 25, in <module>
    from sqlalchemy import orm, event, inspect
ImportError: cannot import name inspect

Searching for answer I learned that the reason is that my Python environment is somehow broken, but I have no idea how can I fix the OpenShift environment. What should I do?

Upvotes: 3

Views: 2129

Answers (2)

BMW
BMW

Reputation: 499

OpenShift dependencies can be specified in requirements.txt:

Flask>=0.10.1                                                                   
Flask-SQLAlchemy>=2.1                                                           
SQLAlchemy>=1.0.12 

The Flask-SQLAlchemy v2.1 setup.py contains:

install_requires=['Flask>=0.10',
                  'SQLAlchemy>=0.8.0']

Including SQLAlchemy (in addition to Flask-SQLAlchemy) in your requirements will fix the dependency issue mentioned by @davidism.

Upvotes: 0

davidism
davidism

Reputation: 127180

You have a very old version of SQLAlchemy. The inspect system was added in version 0.8, in 2012. The current version is 1.0. Recent Flask-SQLAlchemy changes dropped support for very old versions of SQLAlchemy. Upgrade to a newer version.

pip install -U sqlalchemy

Upvotes: 5

Related Questions