2015-08-21 83 views
3

我是Centos 6Linux的新手。
我需要安裝Python 3.4,但Centos 6默認爲Python 2.6.6。我已經安裝了Python 3.4/usr/local/lib/Python3.4

但是,我在安裝mysqlclient時遇到問題。我試過pip3.4 install mysqlclient

這是錯誤消息。Centos 6 - sudo在爲Python 3.4安裝mysqlclient時無法識別pip3.4

錯誤

_mysql.c:29:23: error: my_config.h: No such file or directory 
_mysql.c:30:19: error: mysql.h: No such file or directory 
_mysql.c:31:26: error: mysqld_error.h: No such file or directory 
_mysql.c:51:20: error: errmsg.h: No such file or directory 
_mysql.c:74: error: expected specifier-qualifier-list before ‘MYSQL 
_mysql.c:88: error: expected specifier-qualifier-list before ‘MYSQL_RES’ 
_mysql.c: In function ‘_mysql_Exception’: 
_mysql.c:128: warning: implicit declaration of function ‘mysql_errno’ 
_mysql.c:128: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’ 
_mysql.c:131: error: ‘CR_MAX_ERROR’ undeclared (first use in this function) 
_mysql.c:131: error: (Each undeclared identifier is reported only once 
_mysql.c:131: error: for each function it appears in.) 
_mysql.c:139: error: ‘CR_COMMANDS_OUT_OF_SYNC’ undeclared (first use in this function) 
_mysql.c:140: error: ‘ER_DB_CREATE_EXISTS’ undeclared (first use in this function) 
_mysql.c:141: error: ‘ER_SYNTAX_ERROR’ undeclared (first use in this function) 
_mysql.c:142: error: ‘ER_PARSE_ERROR’ undeclared (first use in this function) 
_mysql.c:143: error: ‘ER_NO_SUCH_TABLE’ undeclared (first use in this function) 
_mysql.c:144: error: ‘ER_WRONG_DB_NAME’ undeclared (first use in this function) 
_mysql.c:145: error: ‘ER_WRONG_TABLE_NAME’ undeclared (first use in this function) 
_mysql.c:146: error: ‘ER_FIELD_SPECIFIED_TWICE’ undeclared (first use in this function) 
_mysql.c:147: error: ‘ER_INVALID_GROUP_FUNC_USE’ undeclared (first use in this function) 
_mysql.c:148: error: ‘ER_UNSUPPORTED_EXTENSION’ undeclared (first use in this function) 
_mysql.c:149: error: ‘ER_TABLE_MUST_HAVE_COLUMNS’ undeclared (first use in this function) 
_mysql.c:178: error: ‘ER_DUP_ENTRY’ undeclared (first use in this function) 
_mysql.c:221: warning: implicit declaration of function ‘mysql_error’ 
_mysql.c:221: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’ 
_mysql.c: In function ‘_mysql_server_init’: 
_mysql.c:325: warning: label ‘finish’ defined but not use 
_mysql.c:242: warning: unused variable ‘item’ 
_mysql.c:241: warning: unused variable ‘groupc' 
_mysql.c:241: warning: unused variable ‘i’ 
... 

error: command 'gcc' failed with exit status 1 
---------------------------------------- 
Cleaning up... 
Command /usr/local/bin/python3.4 -c "import setuptools, tokenize;__file__= 
'/tmp/pip_build_username/mysqlclient/setup.py'; 
exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" 
install --record /tmp/pip-s1b9rgku-record/install-record.txt 
--single-version-externally-managed --compile failed with error code 1 
in /tmp/pip_build_username/mysqlclient 
     Storing debug log for failure in /home/username/.pip/pip.log 

編輯:發現了什麼是錯誤的。 Sudo不承認pip3.4。此鏈接有助於:Installing Python3.4 and the SciPy stack on CentOS

sudo /usr/local/bin/pip3.4 install mysqlclient 
+2

嗨,你說明什麼** /首頁/用戶名/將該.pip/pip.log **日誌文件包含? – Kadir

+0

有什麼之前的行「錯誤:命令'gcc'失敗,退出狀態1」? – scytale

+0

@scytale - 有一個很長的列表,但這是它的一部分,直到'...',其餘的是一堆消息,抱怨它無法找到成員或初始化錯誤。 – Cryssie

回答

6

您是否先安裝了mysqlclient(rpm)?聽起來就像是找不到頭的需求

須藤yum的安裝mysql的mysql-devel的mysql的-lib的

看到http://www.cyberciti.biz/faq/centos-linux-56-install-mysql-client-only/

+0

我試過了,它仍然抱怨說它無法找到MySQLdb模塊,當我運行我的腳本。每當我嘗試使用pip3.4來安裝任何軟件包時,它都不起作用。 – Cryssie

+0

是否有python 3的mysqldb模塊?對於python 3,我使用mysql連接器(因爲它沒有任何依賴關係 - 不需要安裝mysql).sudo pip install --allow-external mysql-connector-python mysql-connector-python然後導入mysql.connector,然後其餘的調用幾乎完全相同,請參閱http://dev.mysql.com/doc/connector-python/en/ – lxx

+0

是的它是mysqlclient。相同的腳本在Windows環境中工作正常。我必須將我的腳本遷移到Linux服務器進行測試。如果我使用pip安裝mysqlclient - 它會安裝到python 2.6.6,如果我使用'sudo pip3.4安裝mysqlclient',它會抱怨它無法識別pip3.4。 – Cryssie