2011-04-01 143 views
0

我試圖在我的EC2實例上部署我的項目。 當我運行python manage.py validate時出現此錯誤Error: No module named mysql.base 亞馬遜EC2上的Django syncdb問題

我已經使用yum install MySQL-python安裝了MySQL-python。我可以從Python解釋器成功導入MySQLdb。

我似乎無法弄清楚什麼是錯的?

我使用Django 1.3和Python 2.6 MySQLdb的1.2.3c1

UPDATE 好吧,我發現在以下目錄中/usr/lib/python2.6/site-packages//usr/lib**64**/python2.6/site-packages/而不是MySQL-python的文件。所以,現在我想通過wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download手動下載MySQL-python的文件,同時在我的/usr/lib/python2.6/site-packages/目錄,現在我得到這個錯誤,當我運行python setup.py build

running build 
running build_py 
creating build 
creating build/lib.linux-x86_64-2.6 
copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.6 
creating build/lib.linux-x86_64-2.6/MySQLdb 
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.6/MySQLdb 
copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.6/MySQLdb 
copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.6/MySQLdb 
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.6/MySQLdb 
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.6/MySQLdb 
copying MySQLdb/times.py -> build/lib.linux-x86_64-2.6/MySQLdb 
creating build/lib.linux-x86_64-2.6/MySQLdb/constants 
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants 
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants 
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants 
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants 
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants 
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants 
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants 
running build_ext 
building '_mysql' extension 
creating build/temp.linux-x86_64-2.6 
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/usr/include/python2.6 -c _mysql.c -o build/temp.linux-x86_64-2.6/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -DUNIV_LINUX 
unable to execute gcc: No such file or directory 
error: command 'gcc' failed with exit status 1 

OS詳細

Amazon Linux AMI Base 2011.02.1, EBS boot, 64-bit architecture with Amazon EC2 AMI Tools 
The Amazon Linux AMI is based on RHEL 5.x and parts of RHEL6 

UPDATE 我重新做了一個32位實例的項目,它的工作原理。

回答

0

嘗試用

pip install mysql-python 

easy_install mysql-python 

或者下載安裝包,然後使用Python腳本安裝setup.py

編輯:

嘗試在做進口蟒蛇殼

from mysql.base import * 

或剛剛推出

python manage.py shell 

如果能夠這樣做,很可能有一些錯誤/home/djangotest/sgelections/apache/django.wsgi

一個極端的例子( lol):

import sys 
sys.path = [] 
+0

我試過的easy_install並手動下載軟件包,它仍然不起作用。 – super9 2011-04-02 04:49:16

+0

我試過'從mysql.base import *'和'python manage.py shell'。他們都導致了同樣的錯誤。 – super9 2011-04-04 03:18:54

+0

我已更新問題以反映我的進度 – super9 2011-04-04 03:56:14

0

你在使用什麼操作系統? 默認安裝了python 2.6,你自己安裝了嗎?

我問這個問題的原因是因爲當你使用yum install的時候,它會爲你的操作系統上安裝的python版本安裝mysql-python客戶端,對於CentOS 5.5,它是python2.4.x。

如果您使用python的alt-install選項手動安裝了python2.6,那麼mysql-python在你的機器上安裝的默認版本是python,但不是你的python2.6。

如果你進入/usr/lib/python2.6/site-packages,你會看到MySQL_python嗎?如果沒有,那麼你需要使用easy_install或pip重新安裝它,或者自己下載mysql-python包,然後手動安裝它。或者,您可以添加它現在安裝到您的Python路徑。

如果你在你的機器上搜索MySQL_python,你可以看到它現在安裝在哪裏,這應該讓你更好地理解發生了什麼。

+0

Python2.6附帶了我的ec2實例。我試過easy_install,但它仍然無法工作。 – super9 2011-04-02 04:50:01

+0

你使用的是什麼Linux發行版和版本?你看看網站包,看是否有mysql-python嗎? – 2011-04-02 11:38:18

+0

我已更新問題以反映解決問題的進度 – super9 2011-04-04 03:55:56

0

打開您的settings.py文件。如果使ENGINEmySQL,你應該改變這樣的:

DATABASES = { 
    'default': { 
    'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 
     'mysql', 'sqlite3' or 'oracle'. 
    ... 
    }