2011-04-01 133 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'. 
    ... 
    }