Python3.2:安装MySQL python失败,错误为“;没有名为ConfigParser的模块;

Python3.2:安装MySQL python失败,错误为“;没有名为ConfigParser的模块;,python,pip,python-3.2,Python,Pip,Python 3.2,我想在MySQL数据库中使用SQLAlchemy。我已经创建了引擎并尝试连接,但出现如下错误 from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base Engine = create_engine('mysql+mysqldb://dbuser:pass@localhost/mydb') Base = declarative_base(Engine) 该操作失败,并出

我想在MySQL数据库中使用SQLAlchemy。我已经创建了引擎并尝试连接,但出现如下错误

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
Engine = create_engine('mysql+mysqldb://dbuser:pass@localhost/mydb')
Base = declarative_base(Engine)
该操作失败,并出现以下错误:

File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/connectors/mysqldb.py", line 57, in dbapi
return __import__('MySQLdb')
ImportError: No module named MySQLdb
通过搜索,我发现您必须安装MySQLdb for python才能更好地使用MySQL。因此,尝试使用pip-3.2或easy_install-3.2安装它会失败,如下所示

sudo pip-3.2 install MySQL-python
Downloading/unpacking MySQL-python
Running setup.py egg_info for package MySQL-python
Traceback (most recent call last):
  File "<string>", line 16, in <module>
  File "/tmp/pip-build/MySQL-python/setup.py", line 14, in <module>
    from setup_posix import get_config
  File "setup_posix.py", line 2, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named ConfigParser
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip-build/MySQL-python/setup.py", line 14, in <module>
from setup_posix import get_config
 File "setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named ConfigParser

关于这一点,MySQLdb不支持python3。试着选择一个有,像(这是)

编辑:还有。

然后,更新settings.py以使用oracle django后端“mysql.connector.django”:


谢谢你。昨天浪费了一整天。我看到有pymysql3和pymysql_-sa,它表示pymysql_-sa是一种用于SQLAlchemy的pymysql方言。那么我应该安装哪个呢?考虑到我专门与sqlalchemy合作,认为pymysql_sa比pymysql3有更多的优势?找到了“硬路”。尝试安装pymysql_sa,但失败。很可能是因为它与Python3不兼容。所以是的,坚持使用pymysql3。谢谢。我试过使用pymysql3和I,正如我指出的,在sqlalchemy中有一个bug。您有解决方法吗?尝试此操作后,我得到“django.core.exceptions.impropertlyconfigured:'mysql.connector.django'不是可用的数据库后端。”
Original exception was:
Traceback (most recent call last):
 File "<string>", line 3, in <module>
 File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.34-py3.2.egg/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.34-py3.2.egg/setuptools/extension.py", line 2, in <module>
import distutils.core
File "/usr/lib/python3.2/distutils/core.py", line 19, in <module>
from distutils.config import PyPIRCCommand
File "/usr/lib/python3.2/distutils/config.py", line 8, in <module>
from configparser import ConfigParser
 File "configparser.py", line 122
sudo pip-3.2 install pymysql3
pip install --user https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-1.1.6.tar.gz
DATABASES = {
    'default': {
        'ENGINE': 'mysql.connector.django',
         ...