2011-01-18 40 views
19

Tôi nhận được lỗi sau khi tôi cố cài đặt MySQL-python-1.2.3 trong Python 2.6 trong Fedora 14.lỗi: Thiết lập kịch bản đã thoát với lỗi: lệnh 'gcc' không thành công với trạng thái thoát 1

Fedora 14 đi kèm với Python 2.7 theo mặc định và tôi đang làm việc trong một dự án chạy trong Python 2.6, Vì vậy, tôi không ở vị trí để cập nhật Python từ 2.6 lên 2.7.

_mysql.c:35:23: fatal error: my_config.h: No such file or directory 
compilation terminated. 
error: command 'gcc' failed with exit status 1 

Các thông báo lỗi được thực hiện như dưới đây

[[email protected] MySQL-python-1.2.2]# python setup.py build 
running build 
running build_py 
creating build 
creating build/lib.linux-i686-2.6 
copying _mysql_exceptions.py -> build/lib.linux-i686-2.6 
creating build/lib.linux-i686-2.6/MySQLdb 
copying MySQLdb/__init__.py -> build/lib.linux-i686-2.6/MySQLdb 
copying MySQLdb/converters.py -> build/lib.linux-i686-2.6/MySQLdb 
copying MySQLdb/connections.py -> build/lib.linux-i686-2.6/MySQLdb 
copying MySQLdb/cursors.py -> build/lib.linux-i686-2.6/MySQLdb 
copying MySQLdb/release.py -> build/lib.linux-i686-2.6/MySQLdb 
copying MySQLdb/times.py -> build/lib.linux-i686-2.6/MySQLdb 
creating build/lib.linux-i686-2.6/MySQLdb/constants 
copying MySQLdb/constants/__init__.py -> build/lib.linux-i686-2.6/MySQLdb/constants 
copying MySQLdb/constants/CR.py -> build/lib.linux-i686-2.6/MySQLdb/constants 
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-i686-2.6/MySQLdb/constants 
copying MySQLdb/constants/ER.py -> build/lib.linux-i686-2.6/MySQLdb/constants 
copying MySQLdb/constants/FLAG.py -> build/lib.linux-i686-2.6/MySQLdb/constants 
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-i686-2.6/MySQLdb/constants 
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-i686-2.6/MySQLdb/constants 
running build_ext 
building '_mysql' extension 
creating build/temp.linux-i686-2.6 
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/usr/include/mysql -I/usr/local/include/python2.6 -c _mysql.c -o build/temp.linux-i686-2.6/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -DUNIV_LINUX 
_mysql.c:35:23: fatal error: my_config.h: No such file or directory 
compilation terminated. 
error: command 'gcc' failed with exit status 1 
[[email protected] MySQL-python-1.2.2]# python2.6 setup.py build 
running build 
running build_py 
copying MySQLdb/release.py -> build/lib.linux-i686-2.6/MySQLdb 
running build_ext 
building '_mysql' extension 
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/usr/include/mysql -I/usr/local/include/python2.6 -c _mysql.c -o build/temp.linux-i686-2.6/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -DUNIV_LINUX 
_mysql.c:35:23: fatal error: my_config.h: No such file or directory 
compilation terminated. 
error: command 'gcc' failed with exit status 1 

Trả lời

7

Giải Quyết vấn đề này theo cách sau

  1. Sao chép MySQLdb thư mục từ trang web gói thư mục của Python2.7 để python2.6 .
  2. Cũng sao chép các tệp sau từ thư mục gói trang web của Python2.7 sang Python2.6.

    _mysql.so

    _mysql_exceptions.py

    _mysql_exceptions.pyc

    _mysql_exceptions.pyo

Bây giờ hãy thử như sau

>>> import MySQLdb 
>>> MySQLdb.__version__ 
'1.2.3' 
37

bạn cần cài đặt gói Phát triển MySQL

yum install mysql-devel 
+0

tôi không thể tìm thấy gói 'mysql-devel' trong linux của kiến ​​trúc. tên của 'mysql-devel' cho arch là gì? –

+0

Thực hiện kiểm tra nhanh với google và theo trang web này https://www.archlinux.org/packages/extra/x86_64/mysql-python/ nó có thể là 'libmariadbclient'. Tôi chưa bao giờ sử dụng arch-linux trước đây – eos87

13

Cài đặt python-devel. Điều đó sẽ giúp

Các vấn đề liên quan