简体   繁体   中英

not able to import pymysql module in python3

I have downloaded the PyMySql using sudo pip3 install pymysql and it showed that python module was installed successfully. 在此处输入图片说明

But when I try to import it, it is showing that no module is available with this name. 在此处输入图片说明

Actually I was writing a playbook for mysql root user password updation in Ansible where Ansible needs this pymysql module.

The ansible script is not getting PyMySql or MySql-python as it is shown in the second image. You have to check which python version you are using for ansible and fix the python path in ansible script to show where your PyMySql module is.

As this is a problem related to ansible, you can add the tag ansible for this question.

Can you try the below command ?

python3 -m pip3 install pymysql

and then use

import pymysql

in your command?

To work mysql, we need mysql driver and programming language specific client library. Looks you have installed client libraries.

Check on how to install driver as per your operating system.

Hope this helps.

在此处输入图片说明

I logged in as root user then uninstalled the previously installed pymysql and then again installed the pymysql from root user and now it is working perfectly fine. so try to avoid installing something from pip using sudo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM