How to install MySQLdb package? (ImportError: No module named setuptools)

后端 未结 11 1052
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-25 10:20

I am trying to install MySQLdb package. I found the source code here.

I did the following:

gunzip MySQL-python-1.2.3c1.tar.gz
tar xvf MySQL-python-1.         


        
相关标签:
11条回答
  • 2020-12-25 11:15

    @main:

    $ su
    $ yum install MySQL-python
    

    and it will be installed (MySQLdb).

    0 讨论(0)
  • 2020-12-25 11:15

    For Python 2.7, one can easily install using this

    apt-get install python2.7-mysqldb

    0 讨论(0)
  • 2020-12-25 11:17

    This was sort of tricky for me too, I did the following which worked pretty well.

    • Download the appropriate Python .egg for setuptools (ie, for Python 2.6, you can get it here. Grab the correct one from the PyPI site here.)
    • chmod the egg to be executable: chmod a+x [egg] (ie, for Python 2.6, chmod a+x setuptools-0.6c9-py2.6.egg)
    • Run ./[egg] (ie, for Python 2.6, ./setuptools-0.6c9-py2.6.egg)

    Not sure if you'll need to use sudo if you're just installing it for you current user. You'd definitely need it to install it for all users.

    0 讨论(0)
  • 2020-12-25 11:18

    well installing C compiler or GCC didn't work but I found a way to successfully install mysqldb package

    kindly follow Mike schrieb's (Thanks to him) instructions here . In my case, I used setuptools-0.6c11-py2.7.egg and setuptools-0.6c11 . Then download the executable file here then install that file. hope it helps :)

    0 讨论(0)
  • 2020-12-25 11:21

    After trying many suggestions, simply using sudo apt-get install python-mysqldb worked for me.

    More info: Getting "Error loading MySQLdb module: No module named MySQLdb" - have tried previously posted solutions

    0 讨论(0)
提交回复
热议问题