安装 flask-mysql python 模块时出错

Error installing flask-mysql python module

我正在尝试安装 flask-mysql 模块,但 运行 出错了。 vcvarsall.bat 似乎有问题,但我不太确定这暗示了什么。

比我更有经验的人有什么想法吗?

C:\eb-virt\bucketlist>pip install flask-mysql

Collecting flask-mysql
  Using cached Flask_MySQL-1.3-py2.py3-none-any.whl
Collecting MySQL-python (from flask-mysql)
  Using cached MySQL-python-1.2.5.zip
Requirement already satisfied (use --upgrade to upgrade): Flask in c:\python27\lib\site-packages (from flask-mysql)
Requirement already satisfied (use --upgrade to upgrade): itsdangerous>=0.21 in c:\python27\lib\site-packages (from Flask->flask-mysql)
Requirement already satisfied (use --upgrade to upgrade): click>=2.0 in c:\python27\lib\site-packages (from Flask->flask-mysql)
Requirement already satisfied (use --upgrade to upgrade): Werkzeug>=0.7 in c:\python27\lib\site-packages (from Flask->flask-mysql)
Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in c:\python27\lib\site-packages (from Flask->flask-mysql)
Requirement already satisfied (use --upgrade to upgrade): MarkupSafe in c:\python27\lib\site-packages (from Jinja2>=2.4->Flask->flask-mysql)
Installing collected packages: MySQL-python, flask-mysql
  Running setup.py install for MySQL-python ... error
    Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\users\tonype~1\appdata\local\temp\pip-build-3xn7it\MySQL-python\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\tonype~1\appdata\local\temp\pip-vtdlrx-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-2.7
    copying _mysql_exceptions.py -> build\lib.win-amd64-2.7
    creating build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\release.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\times.py -> build\lib.win-amd64-2.7\MySQLdb
    creating build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    running build_ext
    building '_mysql' extension
    error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27

    ----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\users\tonype~1\appdata\local\temp\pip-build-3xn7it\MySQL-python\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\tonype~1\appdata\local\temp\pip-vtdlrx-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\tonype~1\appdata\local\temp\pip-build-3xn7it\MySQL-python\

您可以尝试使用这些 binaries for windows distributions. Flask-mysql uses mysql-python which has issues when trying to install on windows. See this

当您安装 python 32 位 和 mysql 64 位 或反之反之亦然。尝试相同的安装。我在这个命令 postgresSql 和 python 中遇到了这个错误 pip install psycopg2 也许这会解决您的问题。