2016-08-05 94 views
1

如果這是一個簡單的修復程序,我已經提前道歉,我已經搜索了一個沒有運氣的答案。通過pip-3.4在亞馬遜Linux AMI上安裝mysql-connector-python時出錯

我試圖在亞馬遜的Linux AMI上安裝mysql-connector [-python]包。爲了我的目的,我想使用Python 3.4。我已經安裝了Python 3.4和PIP-3.4與百勝集團並已成功地安裝了幾包已經:

pip-3.4 list 

numpy (1.11.1) 
    pip (6.1.1) 
    setuptools (25.1.4) 
    virtualenv (15.0.2) 

然而,當我嘗試:

sudo pip-3.4 install mysql-connector-python 

我得到

Collecting mysql-connector-python 
    Could not find a version that satisfies the requirement mysql-connector-python (from versions:) 
    No matching distribution found for mysql-connector-python 

sudo pip-3.4 install mysql-connector-python --allow-external mysql-connector-python給出了相同的錯誤。谷歌搜索建議我用sudo pip-3.4 install mysql-connector-python-rf --allow-external mysql-connector-python-rf但隨後這給出了錯誤:

Collecting mysql-connector-python-rf 
    Using cached mysql-connector-python-rf-2.1.3.tar.gz 
    Installing collected packages: mysql-connector-python-rf 
    Running setup.py install for mysql-connector-python-rf 
    Complete output from command /usr/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-hotls6f7/mysql-connector-python-rf/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-wzpbgx5g-record/install-record.txt --single-version-externally-managed --compile: 
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] 
    or: -c --help [cmd1 cmd2 ...] 
    or: -c --help-commands 
    or: -c cmd --help 

error: option --single-version-externally-managed not recognized 

---------------------------------------- 
Command "/usr/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-hotls6f7/mysql-connector-python-rf/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-wzpbgx5g-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-hotls6f7/mysql-connector-python-rf 

我已經嘗試了一些東西,比如

echo https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.3.tar.gz >> requirements.txt 
    sudo -H pip-3.4 install -r ./requirements.txt 

這給類似的錯誤,

sudo pip-3.4 install https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.3.tar.gz 

它給出了相同的error: option --single-version-externally-managed not recognized錯誤。我還應該注意,點子表明我升級使用sudo pip-3.4 install --upgrade pip,但是當我完成這個點子時,即使pip-3.4 listpip-3.4 --version也給我pkg_resources.VersionConflict: (pip 8.1.2 (/usr/local/lib/python3.4/site-packages), Requirement.parse('pip==6.1.1'))

我有些不知所措,任何幫助將不勝感激。

回答

4

在這裏回答我自己的問題,我知道它並不能解決我直接遇到的問題,但我設法安裝了mysql連接器,以便在Python3(.4),import mysql.connector中不給出任何錯誤。下面是我所做的:

wget http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip#md5=3df394d89300db95163f17c843ef49df 
    unzip mysql-connector-python-2.0.4.zip 
    cd mysql-connector-python-2.0.4 
    sudo python3 setup.py install 

現在,在Python3:

>>>import mysql.connector 
    >>> 

我仍然好奇,爲什麼我之前已經得到了錯誤error: option --single-version-externally-managed not recognized。我的猜測是這是setuptools的問題,但我已將其升級到最新版本(以及virtualenv)。

+0

當前是:http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.6.zip –

+0

對於任何人,尋找從哪裏獲得最新版本,請使用鏈接:https://dev.mysql.com/downloads/connector/python/並選擇了「獨立平臺」版本。有關如何使用連接器的示例,請訪問:https://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html – lazyList