No module named 'pymysql'

后端 未结 14 1719
清酒与你
清酒与你 2020-12-15 02:32

I\'m trying to use PyMySQL on Ubuntu.

I\'ve installed pymysql using both pip and pip3 but every time I use import pymysq

相关标签:
14条回答
  • 2020-12-15 03:08

    For windows or one using google colab, you can try this

    !pip install pymysql
    import pymysql
    
    0 讨论(0)
  • 2020-12-15 03:08

    I had this same problem just now, and found the reason was my editor (Visual Studio Code) was running against the wrong instance of python; I had it set to run again python bundled with tensorflow, I changed it to my Anaconda python and it worked.

    0 讨论(0)
  • 2020-12-15 03:09
    1. Make sure that you're working with the version of Python that think you are. Within Python run import sys and print(sys.version).

    2. Select the correct package manager to install pymysql with:

      • For Python 2.x sudo pip install pymysql.
      • For Python 3.x sudo pip3 install pymysql.
      • For either running on Anaconda: sudo conda install pymysql.
      • If that didn't work try APT: sudo apt-get install pymysql.
    3. If all else fails, install the package directly:

      • Go to the PyMySQL page and download the zip file.
      • Then, via the terminal, cd to your Downloads folder and extract the folder.
      • cd into the newly extracted folder.
      • Install the setup.py file with: sudo python3 setup.py install.

    This answer is a compilation of suggestions. Apart from the other ones proposed here, thanks to the comment by @cmaher on this related thread.

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

    Sort of already answered this in the comments, but just so this question has an answer, the problem was resolved through running:

    sudo apt-get install python3-pymysql
    
    0 讨论(0)
  • 2020-12-15 03:16

    if you are using SPYDER IDE , just try to restart the console or restart the IDE, it works

    0 讨论(0)
  • 2020-12-15 03:19

    Just a note: for Anaconda install packages command:

    1. python setup.py install
    0 讨论(0)
提交回复
热议问题