Skip to content Skip to sidebar Skip to footer

Cannot Import Name Util

I'm trying to use SQLAlchemy. However I am unable to import it into my python script. I've activated the python console and inputed 'import sqlalchemy' and it throws me and error a

Solution 1:

My answer is mostly unrelated to the original question and circumstances, but this thread appears as the first question when searching for the error-message and it was a pita to fix this, so I might as well add my case with Pyramid and SQLAlchemy:

In conjunction with Pyramid, I had the same error ("ImportError: cannot import name util"). After hours of trial and error the only reason turned out that in production.ini I had set:

[server:main]use = egg:waitress#mainhost = 0.0.0.0port = 80

I was also using Apache2 on port 80, seemed odd that this should be the same. After changing the port to e.g. 6543, the error disappeared and the WSGI server worked. None of the apache2-settings (WSGIPythonHome,WSGIPythonPath) where necessary.

Apparently unrelated and I don't know why the port-conflict caused this error, but it might help someone else with this issue.

Solution 2:

util is under sqlalchemy.orm so from sqlalchemy.orm import util should work

Post a Comment for "Cannot Import Name Util"