用於按照預期在Python 2.6中工作的Mysql.connector,但是因爲我想使用argparse,所以我安裝了2.7版本。在將連接器安裝到此版本時,我遇到了以下錯誤。我不知道如何解決它們。在從2.6遷移後在Python 2-7中安裝mysql.connector時出現問題
**Error while importing connector:**
[/usr/local/bin ] # python
Python 2.7.6 (default, Apr 19 2016, 19:36:47)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mysql.connector
>>>
**Paths located**
[~ ] # which python2.6
/usr/bin/python2.6
[~ ] # which python2.7
/usr/local/bin/python2.7
[~ ] # which python
/usr/local/bin/python
[~ ] # ls -l /usr/local/bin/py*
-rwxr-xr-x 1 root root 84 Apr 19 18:10 /usr/local/bin/pydoc
lrwxrwxrwx 1 root root 18 Apr 19 21:57 /usr/local/bin/python -> /usr/bin/python2.6
lrwxrwxrwx 1 root root 9 Apr 19 18:10 /usr/local/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 6214541 Apr 19 19:36 /usr/local/bin/python2.7
-rwxr-xr-x 1 root root 1674 Apr 19 19:36 /usr/local/bin/python2.7-config
lrwxrwxrwx 1 root root 16 Apr 19 18:10 /usr/local/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 14 Apr 19 18:10 /usr/local/bin/python-config -> python2-config
[~ ] # pip -V
pip 7.1.0 from /usr/lib/python2.6/site-packages (python 2.6)
**Trying to install mysql connector for python 2.7**
[/usr/src ] # rpm -i mysql-connector-python-2.0.4-1.el7.noarch.rpm
error: Failed dependencies:
python(abi) = 2.7 is needed by mysql-connector-python-2.0.4-1.el7.noarch