【问题标题】:Error installing flask-mysql python module安装flask-mysql python模块时出错
【发布时间】:2016-11-29 10:35:01
【问题描述】:

我正在尝试安装 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\

【问题讨论】:

  • 它需要一些原生代码编译。您需要一个 Visual c++ 2008 (aka VS 9.0) 版本,它与编译 python 2.7 本身的版本相同。有一个专门用于 python 2.7 模块的微软编译器here。不过我从来没有尝试过。
  • 还要确保你安装了正确的mysql(x86 vs x64)

标签: python flask flask-mysql


【解决方案1】:

您可以尝试将这些binaries 用于windows 分发。尝试在 Windows 上安装时,Flask-mysql 使用具有 issues 的 mysql-python。见this

【讨论】:

  • 谢谢!您答案中的最后一个链接解决了我的问题:)
【解决方案2】:

当你安装了 python 32bit 和 mysql 64bit 时,通常会发生这种类型的错误,反之亦然。尝试相同的安装。我在这个命令 pip install psycopg2 上使用 postgresSql 和 python 遇到了这个错误 也许这会解决你的问题。

【讨论】:

    猜你喜欢
    • 2012-01-04
    • 1970-01-01
    • 2011-06-06
    • 2015-07-16
    • 2014-08-30
    • 1970-01-01
    • 2014-10-13
    • 1970-01-01
    相关资源
    最近更新 更多