2013-04-15 85 views
0

我在Windows 7上,我安装了Mysql 5.5后出现了很多问题,python 3.3和django 1.5.1,我创建在MySQL数据库,当我在第一次运行python manage.py syncdb我得到SyntaxError: invalid syntax (connections.py, line 36)SyntaxError:运行python时无效的语法(connections.py,第36行)manage.py syncdb

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 
     'NAME': 'test_django',      # Or path to database file if using sqlite3. 
     # The following settings are not used with sqlite3: 
     'USER': 'root', 
     'PASSWORD': 'root', 
     'HOST': 'localhost',      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. 
     'PORT': '3306',      # Set to empty string for default. 
    } 
} 

课程的密码和数据库名称是否正确。有任何想法吗?

编辑 - connections.py是MySQLdb的模块中,在第36行有

raise errorclass, errorvalue 

我怎样才能看到回溯?

+0

@Wooble什么文件?我没有触及django标准安装,我无法找到django文件夹中的文件connections.py。我正在按照教程https://docs.djangoproject.com/en/1.5/intro/tutorial01/ –

+0

connections.py,大概。 – geoffspear

+0

@Wooble ok connections.py在MySQLdb扩展中......在第35行有 del连接 –

回答

0

您未使用最新版本的Django 1.5,它是第一个与Python 3兼容的版本。早期的Django版本只与Python 2.x兼容。

+0

不,我使用的是1.5.1,对不起,我没有指定 –

+0

你知道为什么我没有看到回溯?看起来是一个异常在第36行,但没有回溯 –

0

我有同样的线路36语法错误并解决它 这是MySQL驱动程序的使用Python 3的不匹配导致该 http://bunwich.blogspot.com/2014/02/finally-mysql-connector-that-works-with.html可以用这个

还可以帮助:

DATABASES = { 
    'default': { 
     'NAME': 'mydatabase', 
     'ENGINE': 'mysql.connector.django', 
     'USER': 'myuser', 
     'PASSWORD': 'secretpassword', 
     'OPTIONS': { 
      'autocommit': True, 
     }, 
    } 
} 

注意ENGINE是mysql.connector.django而不是django.db.backends.mysql

相关问题