ubuntu安装mysql连接依赖报错问题处理

首先报错如下

from mysql import connector ImportError: No module named 'mysql'

然后尝试安装依赖

执行命令

python -m pip install mysql-connector-python-rf -i https://pypi.douban.com/simple/

报如下错

$ python -m pip install mysql-connector-python-rf
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Collecting mysql-connector-python-rf
  Downloading mysql-connector-python-rf-2.2.2.tar.gz (11.9 MB)
     |▊                               | 286 kB 36 kB/s eta 0:05:24^C
ERROR: Operation cancelled by user
(py35) EUROPROyanyan.zhao@bej-lt-pf28l83e:~/scode/kitchen_survey$ python -m pip install mysql-connector-python-rf -i https://pypi.douban.com/simple/
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Looking in indexes: https://pypi.douban.com/simple/
Collecting mysql-connector-python-rf
  Using cached https://mirrors.cloud.tencent.com/pypi/packages/21/79/2ff01ab7aa08db3a16b70b990c579c1024c6b2a734263cc7513a758867de/mysql-connector-python-rf-2.2.2.tar.gz (11.9 MB)
Using legacy 'setup.py install' for mysql-connector-python-rf, since package 'wheel' is not installed.
Installing collected packages: mysql-connector-python-rf
    Running setup.py install for mysql-connector-python-rf ... error
    ERROR: Command errored out with exit status 1:
     command: /home/local/EUROPRO/yanyan.zhao/.myvirtualenv/py35/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-h75jxbig/mysql-connector-python-rf_2c9be97a3b634fc4a69488f4c8ac56c4/setup.py'"'"'; __file__='"'"'/tmp/pip-install-h75jxbig/mysql-connector-python-rf_2c9be97a3b634fc4a69488f4c8ac56c4/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
'"'"', '"'"'
'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-d8bsro4j/install-record.txt --single-version-externally-managed --compile --install-headers /home/local/EUROPRO/yanyan.zhao/.myvirtualenv/py35/include/site/python3.5/mysql-connector-python-rf
         cwd: /tmp/pip-install-h75jxbig/mysql-connector-python-rf_2c9be97a3b634fc4a69488f4c8ac56c4/
    Complete output (6 lines):
    usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: setup.py --help [cmd1 cmd2 ...]
       or: setup.py --help-commands
       or: setup.py cmd --help
    
    error: option --single-version-externally-managed not recognized
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/local/EUROPRO/yanyan.zhao/.myvirtualenv/py35/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-h75jxbig/mysql-connector-python-rf_2c9be97a3b634fc4a69488f4c8ac56c4/setup.py'"'"'; __file__='"'"'/tmp/pip-install-h75jxbig/mysql-connector-python-rf_2c9be97a3b634fc4a69488f4c8ac56c4/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
'"'"', '"'"'
'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-d8bsro4j/install-record.txt --single-version-externally-managed --compile --install-headers /home/local/EUROPRO/yanyan.zhao/.myvirtualenv/py35/include/site/python3.5/mysql-connector-python-rf Check the logs for full command output.

解决方式:先安装wheel

python -m pip install wheel -i https://pypi.douban.com/simple/

python -m pip install mysql-connector-python-rf -i https://pypi.douban.com/simple/

到此就安装成功了