I'm following precisely your Flask Mega-Tutorial (I bought the book ;-)).
I'm using windows, and pipenv for my virtual environments.
After executing p.40 << flask db init >> command I gave a look to the env.py file and pylint showed the error in the subject:
_Module 'alembic.context' has no 'config' member_
Nevertheless I run << flask db migrate -m "users table" >> and I had the following error:
_sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:sqllite_
Thank you in advance.
Roberto
What Python version are you using?
I would not worry about the pylint error for now. Linters are often confused, specially with auto-generated code. What's important is to figure out errors that occur at runtime.
The error that you get when running the flask db migrate command suggests your Python installation does not have the expected stuff. I suggest you try not using pipenv, to see if that helps. I have found pipenv to not be very stable in my own tests, never seen an error like yours, but it would help to rule pipenv out by using straight pip as I show in the tutorial. If that does not help, I would look into reinstalling Python, or getting a newer version if what you are using is too old.
Ok, I was using a quite new home-installation (last month) of all the tools, starting with python 3.
Today, at work, I prepared a fresh new installation environment:
pipenv install flask
pipenv install flask-sqlalchemy
pipenv install flask-migrate
pipenv install flask-wtf
flask db init
flask db migrate -m "users table"
Everything worked as expected in your tutorial.
PyLint is still annoying ([pylint] E1101:Module 'alembic.context' has no 'config' member) but this, of course, is a minor problem.
I will take in account all of your advices, I'll give another chance to pipenv keeping an eye on its instability.
Thank you very much for your time and kindness.
Roberto Vivarelli
Hi, unfortunately at home the problem persists.
First of all I tried avoiding pipenv following tutorial instructions, I got the same:
_sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:sqllite_
Secondly I tried to reset all python installation, uninstalling, cleaning pip cache and starting from python 3.6.5, no good news, same error:
_sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:sqllite_
Tonight I will give another try but I feel blind and I expect the same result.
So, the situation is: two windows 10 PCs with python 3.6, the job one working, the home one not.
Thanks.
Roberto
Hello,
I can't believe it but after an accurate cleaning of the python stuff
I installed python 3.6 with python-3.6.5-amd64.exe (checking MD5) in c:\Python36 (this time avoiding "Program Files" directory).
After that I followed the tutorial steps (as you can see in the log file).
Same error:
_sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:sqllite_
If you don't have any ideas,
I think I will try to use flask without flask-migrate.
Thank you very much.
Roberto
20180417_pip_flask.txt
Start a python shell in your virtual environment and run the following:
import sqlalchemy.dialects.sqlite
Does that work or give you errors?
Thank you for you reply, it works:
(venv) E:\Work\Flask\FicoBlog>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlalchemy.dialects.sqlite
>>>
>>> dir( sqlalchemy.dialects.sqlite )
['BLOB', 'BOOLEAN', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'FLOAT', 'INTEGER', 'NUMERIC', 'REAL', 'SMALLINT', 'TEXT', '
TIME', 'TIMESTAMP', 'VARCHAR', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__'
, '__package__', '__path__', '__spec__', 'base', 'dialect', 'pysqlcipher', 'pysqlite']
Other checks to do?
I encountered the same problem on a different project, mainly pylint complaining about the same issue and for good reasons. I was able to replicate the problem easily:
>python
Python 2.7.14 (default, Nov 28 2017, 20:12:14)
from alembic import context
config = context.config
AttributeError: 'module' object has no attribute 'config'
dir(context)
Out[5]:
['EnvironmentContext',
'__builtins__',
'__doc__',
'__file__',
'__name__',
'__package__',
'_name_error',
'begin_transaction',
'configure',
'create_module_class_proxy',
'execute',
'get_bind',
'get_context',
'get_head_revision',
'get_head_revisions',
'get_impl',
'get_revision_argument',
'get_starting_revision_argument',
'get_tag_argument',
'get_x_argument',
'is_offline_mode',
'is_transactional_ddl',
'requires_connection',
'run_migrations',
'static_output']
In case it matters, I am using pyenv 2.7 on MacOS, alembic is 0.9.9
Any ideas?
@RobiIhs and @ssbarnea were you able to resolve this?
I had a similar issue but turns out I had a typo in my config.py especially around sqlite:/// path.
@RobiIhs As @vishalraina mentioned, please make sure it's sqlite:/// and NOT sqlllite:///. I was having the same issue until I fixed the type.
Thank you very much. That was the problem.
I wrote "sqllite" instead of "sqlite" in DATABASE URI string.
I apologize for my stupid mistake.
Hahaha... I got the same issue and I found out I made the same mistake.
Thank you all!
I just made the same mistake as well, thanks for everyone who posted, helped me detect it.
same here....
Yeah, me too. Why is that such an easy mistake?
sqllite is error should sqlite => sqlite:///test.db
I had a typo in my keystone.conf connection string written as mysql+pymsql:// instead of mysql+pymysql://. Thanks for pointing me to the solution!
I made the same mistake XD
This chat is hilarious.. dis the same thing!
'sqlite:///xyz.db' naming issue is the most prevalent ones
@RobiIhs and @ssbarnea were you able to resolve this?
I had a similar issue but turns out I had a typo in my config.py especially around sqlite:/// path.
I had this error when instead of using sqlite, i used sqllite....
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///goda.db'
Changed the typo and it worked like charm
I am a complete noob to Python (come from JS and Java world)
Had the same error but i fixed it, i changed app.config['SLQALCHEMY_DATABASE_URI'] = 'posgresql://... to app.config['SQLALCHEMY_DATABASE_URI'] = 'posgresql://...
Changed the SLQ to SQL
[EDIT] Still not working, i have this error "Can't load plugin: %s:%s" % (self.group, name)
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:posgresql
Alright, was a mistake, i had _posgresql_ instead of _postgresql_
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:posgresql
gives this error when information is sent to the database
how can i solve this issue
@mmuokuba The name is postgresql, not posgresql.
Most helpful comment
@RobiIhs As @vishalraina mentioned, please make sure it's sqlite:/// and NOT sqlllite:///. I was having the same issue until I fixed the type.