Python3 + MySql: Error loading MySQLdb module: No module named 'MySQLdb'

前端 未结 5 2009
小鲜肉
小鲜肉 2020-12-28 16:40

I am new to Python and trying to setup a Django project to work with MySql. I have read through the documentation as well as some other StackOverflow posts about the topic,

5条回答
  •  旧巷少年郎
    2020-12-28 17:05

    If you're like me, you're working with a Linux install, and Linux still needs Python 2.7 in most cases. That means that

    pip install mysqlclient
    

    will install the MySQL client for 2.7, which is segmented from Python 3. To make it install for 3.x you need to use

    pip3 install mysqlclient
    

    I did not have to install any packages, but mysql-common was already installed (Raspbian install) so your mileage may vary there

提交回复
热议问题