Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

After finishing of one of my Flask projects, I uploaded it on github just like everybody else.

(在完成我的一个Flask项目之后,我像其他人一样将其上传到了github。)

after a 2-3 months period I downloaded the entire githube repository on another machine to run it.

(在2-3个月的时间后,我将整个githube存储库下载到另一台计算机上以运行它。)

However, the app is not working because the packages are not found giving the following message

(但是,该应用程序无法正常运行,因为找不到提供以下消息的软件包)

ModuleNotFoundError: No module named 'Flask'

(ModuleNotFoundError:没有名为“ Flask”的模块)

So I ended up downloading all packages starting from Flask, SQLalchemy,..etc!

(因此,我最终下载了从Flask,SQLalchemy等所有软件包。)

but I got stuck with MySQLdb :

(但是我被MySQLdb卡住了:)

(MYAPPENV) C:Usershpmyapp>python run.py
Traceback (most recent call last):
  File "run.py", line 1, in <module>
    from app import app
  File "C:Usershpmyappapp\__init__.py", line 4, in <module>
    from instance.config import engine
  File "C:Usershpmyappinstanceconfig.py", line 52, in <module>
    engine = create_engine("mysql://root:root@localhost/MYAPPDB")
  File "C:UsershpAppDataLocalProgramsPythonPython37-32libsite-packagessqlalchemyengine\__init__.py", line 425, in create_engine
return strategy.create(*args, **kwargs)
  File "C:UsershpAppDataLocalProgramsPythonPython37-32libsite-packagessqlalchemyenginestrategies.py", line 81, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
  File "C:UsershpAppDataLocalProgramsPythonPython37-32libsite-packagessqlalchemydialectsmysqlmysqldb.py", line 102, in dbapi
    return __import__('MySQLdb')
ModuleNotFoundError: No module named 'MySQLdb'

Could anybody please help with this issue?

(有人可以帮忙解决这个问题吗?)

I am using python37 on windows machine.

(我在Windows机器上使用python37。)

I even tried downloading packages such as mysqlclient,..etc but it didn't work out.

(我什至尝试下载软件包,例如mysqlclient,.. etc,但没有成功。)

  ask by Belle translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
539 views
Welcome To Ask or Share your Answers For Others

1 Answer

I have read that mysqldb is not supported by python3

(我已经读过python3不支持mysqldb)

And it looks like when you are trying to connect to your database you are using mysql db to connect to the database by default!

(看起来,当您尝试连接数据库时,默认情况下使用的是mysql db连接数据库!)

you need to change it by editing your DATABASE_URI configuration

(您需要通过编辑DATABASE_URI配置进行更改)

But before you need to install the connector extension :

(但是在您需要安装连接器扩展之前:)

with this command :

(使用此命令:)

pip install mysql-connector-python

And according to this documentation you can edit your DATABSE_URI and change the default connector like this :

(根据此文档,您可以编辑DATABSE_URI并更改默认的连接器,如下所示:)

DATABSE_URI='mysql+mysqlconnector://{user}:{password}@{server}/{database}'.format(user='your_user', password='password', server='localhost', database='dname')

I hope this will help...

(我希望这个能帮上忙...)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...