I\'m trying to use PyMySQL on Ubuntu.
I\'ve installed pymysql
using both pip
and pip3
but every time I use import pymysq
For windows or one using google colab, you can try this
!pip install pymysql
import pymysql
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.
Make sure that you're working with the version of Python that think you are. Within Python run import sys
and print(sys.version)
.
Select the correct package manager to install pymysql with:
sudo pip install pymysql
.sudo pip3 install pymysql
.sudo conda install pymysql
.sudo apt-get install pymysql
.If all else fails, install the package directly:
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.
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
if you are using SPYDER IDE , just try to restart the console or restart the IDE, it works
Just a note: for Anaconda install packages command: