No module named 'pymysql'

后端 未结 14 1741
清酒与你
清酒与你 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: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.

提交回复
热议问题