ImportError: No module named mysql.connector using Python2

前端 未结 12 2065
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-13 06:26

I have two files. The first one has the connection and the getting of data. I import mysql.connector. This file is called tasksSql.py

def get_users():
    im         


        
相关标签:
12条回答
  • 2020-12-13 07:00

    What worked for me was to download the .deb file directly and install it (dpkg -i mysql-connector-python_2.1.7-1ubuntu16.04_all.deb). Python downloads are located here (you will need to create a free MySQL login to download first). Make sure you choose the correct version, i.e. (python_2.1.7 vs. python-py3_2.1.7). Only the "Architecture Independent" version worked for me.

    0 讨论(0)
  • 2020-12-13 07:00

    I had problem with my MySQL installation, I was given this error:

    <module> import mysql.connector ModuleNotFoundError: No module named 'mysql' (zrealestate) 
    [root@localhost zrealestate]# brew install mysql
    -bash: brew: command not found
    

    But I resolved it with this:

    pip install mysql-connector-python
    
    0 讨论(0)
  • 2020-12-13 07:01

    I used the following command to install python mysql-connector in Mac. it works

    pip install mysql-connector-python-rf

    0 讨论(0)
  • 2020-12-13 07:01

    If you have this error on PYCHARM: ImportError: No module named mysql.connector

    Try this solution: Open Pycharm go to File->Settings-> Project->Python Interpreter inside Pycharm, Then press + icon to install mysql-connector. Problem solved!

    0 讨论(0)
  • 2020-12-13 07:06

    I use Python 3.4 for windows and installed mysql library from http://dev.mysql.com/downloads/connector/python/

    0 讨论(0)
  • 2020-12-13 07:09

    I was facing the same issue on WAMP. Locate the connectors available with pip command. You can run this from any prompt if Python ENV variables are properly set.

        pip search mysql-connector
    
        mysql-connector (2.2.9)                           - MySQL driver written in Python
        bottle-mysql-connector (0.0.4)                    - MySQL integration for Bottle.
        mysql-connector-python (8.0.15)                   - MySQL driver written in Python
        mysql-connector-repackaged (0.3.1)                - MySQL driver written in Python
        mysql-connector-async-dd (2.0.2)                  - mysql async connection
    

    Run the following command to install mysql-connector

        C:\Users\Admin>pip install mysql-connector
    

    verify the installation

        C:\Users\Admin>python
        Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit 
        (AMD64)] on win32
        Type "help", "copyright", "credits" or "license" for more information.
        >>> import mysql.connector
        >>>
    

    This solution worked for me.

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