无法安装Flask-Mysqldb,软件包安装失败

时间:2019-01-22 10:37:27

标签: powershell installation pipenv flask-mysql

尝试使用pipenv安装flask-mysqldb,但始终收到此锁定错误,然后软件包安装失败。在powershell和命令提示符下进行了尝试,并得到相同的错误。尝试安装其他任何东西(例如passlib)时,我也遇到相同的错误。我将以下过程包括在内。这里可能是什么问题?

PS C:\Users\Kristian.Senior\Documents\User Database> pipenv install flask-mysqldb
Installing flask-mysqldb…
Adding flask-mysqldb to Pipfile's [packages]…
Installation Succeeded
Installing dependencies from Pipfile.lock (f5de99)…
An error occurred while installing mysqlclient==1.4.1 --hash=sha256:6883a4dd98903bad375c859ead1a480e1245ea3a8d9b038ea2c091c1865ba673 --hash=sha256:a62220410e26ce2d2ff94dd0138c3ecfb91db634464a9afb4c8e6b50f0a67e00 --hash=sha256:e1b9f3a8928ddb4985ca3e3c9f2aa81b19e831bbf6fabf5681ee356738dbbbb2! Will try again.
  ================================ 8/8 - 00:00:07
Installing initially failed dependencies…
[pipenv.exceptions.InstallError]:   File "C:\Users\Kristian.Senior\AppData\Roaming\Python\Python37\site-packages\pipenv\core.py", line 1992, in do_install
[pipenv.exceptions.InstallError]:       skip_lock=skip_lock,
[pipenv.exceptions.InstallError]:   File "C:\Users\Kristian.Senior\AppData\Roaming\Python\Python37\site-packages\pipenv\core.py", line 1253, in do_init
[pipenv.exceptions.InstallError]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.InstallError]:   File "C:\Users\Kristian.Senior\AppData\Roaming\Python\Python37\site-packages\pipenv\core.py", line 859, in do_install_dependencies
[pipenv.exceptions.InstallError]:       retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
[pipenv.exceptions.InstallError]:   File "C:\Users\Kristian.Senior\AppData\Roaming\Python\Python37\site-packages\pipenv\core.py", line 763, in batch_install
[pipenv.exceptions.InstallError]:       _cleanup_procs(procs, not blocking, failed_deps_queue, retry=retry)
[pipenv.exceptions.InstallError]:   File "C:\Users\Kristian.Senior\AppData\Roaming\Python\Python37\site-packages\pipenv\core.py", line 681, in _cleanup_procs
[pipenv.exceptions.InstallError]:       raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: ['Collecting mysqlclient==1.4.1 (from -r C:\\Users\\KRISTI~1.SEN\\AppData\\Local\\Temp\\pipenv-iwonkgd4-requirements\\pipenv-lk2odrso-requirement.txt (line 1))', '  Using cached https://files.pythonhosted.org/packages/de/d7/919042fb7ed78a89e21c4e43d5daed90d5df18ec183bae3de493a7d9e3ed/mysqlclient-1.4.1.tar.gz', 'Building wheels for collected packages: mysqlclient', '  Running setup.py bdist_wheel for mysqlclient: started', "  Running setup.py bdist_wheel for mysqlclient: finished with status 'error'", '  Complete output from command c:\\users\\kristian.senior\\.virtualenvs\\user_database-avroy6jj\\scripts\\python.exe -u -c "import setuptools, tokenize;__file__=\'C:\\\\Users\\\\KRISTI~1.SEN\\\\AppData\\\\Local\\\\Temp\\\\pip-install-ebs0lxzd\\\\mysqlclient\\\\setup.py\';f=getattr(tokenize, \'open\', open)(__file__);code=f.read().replace(\'\\r\\n\', \'\\n\');f.close();exec(compile(code, __file__, \'exec\'))" bdist_wheel -d C:\\Users\\KRISTI~1.SEN\\AppData\\Local\\Temp\\pip-wheel-nwzoq5pv --python-tag cp37:', '  running bdist_wheel', '  running build', '  running build_py', '  creating build', '  creating build\\lib.win32-3.7', '  creating build\\lib.win32-3.7\\MySQLdb', '  copying MySQLdb\\__init__.py -> build\\lib.win32-3.7\\MySQLdb', '  copying MySQLdb\\_exceptions.py -> build\\lib.win32-3.7\\MySQLdb', '  copying MySQLdb\\compat.py -> build\\lib.win32-3.7\\MySQLdb', '  copying MySQLdb\\connections.py -> build\\lib.win32-3.7\\MySQLdb', '  copying MySQLdb\\converters.py -> build\\lib.win32-3.7\\MySQLdb', '  copying MySQLdb\\cursors.py -> build\\lib.win32-3.7\\MySQLdb', '  copying MySQLdb\\release.py -> build\\lib.win32-3.7\\MySQLdb', '  copying MySQLdb\\times.py -> build\\lib.win32-3.7\\MySQLdb', '  creating build\\lib.win32-3.7\\MySQLdb\\constants', '  copying MySQLdb\\constants\\__init__.py -> build\\lib.win32-3.7\\MySQLdb\\constants', '  copying MySQLdb\\constants\\CLIENT.py -> build\\lib.win32-3.7\\MySQLdb\\constants', '  copying MySQLdb\\constants\\CR.py -> build\\lib.win32-3.7\\MySQLdb\\constants', '  copying MySQLdb\\constants\\ER.py -> build\\lib.win32-3.7\\MySQLdb\\constants', '  copying MySQLdb\\constants\\FIELD_TYPE.py -> build\\lib.win32-3.7\\MySQLdb\\constants', '  copying MySQLdb\\constants\\FLAG.py -> build\\lib.win32-3.7\\MySQLdb\\constants', '  warning: build_py: byte-compiling is disabled, skipping.', '  ', '  running build_ext', "  building 'MySQLdb._mysql' extension", '  error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/', '  ', '  ----------------------------------------', '  Running setup.py clean for mysqlclient', 'Failed to build mysqlclient', 'Installing collected packages: mysqlclient', '  Running setup.py install for mysqlclient: started', "    Running setup.py install for mysqlclient: finished with status 'error'", '    Complete output from command c:\\users\\kristian.senior\\.virtualenvs\\user_database-avroy6jj\\scripts\\python.exe -u -c "import setuptools, tokenize;__file__=\'C:\\\\Users\\\\KRISTI~1.SEN\\\\AppData\\\\Local\\\\Temp\\\\pip-install-ebs0lxzd\\\\mysqlclient\\\\setup.py\';f=getattr(tokenize, \'open\', open)(__file__);code=f.read().replace(\'\\r\\n\', \'\\n\');f.close();exec(compile(code, __file__, \'exec\'))" install --record C:\\Users\\KRISTI~1.SEN\\AppData\\Local\\Temp\\pip-record-oa9a3r9h\\install-record.txt --single-version-externally-managed --compile --install-headers c:\\users\\kristian.senior\\.virtualenvs\\user_database-avroy6jj\\include\\site\\python3.7\\mysqlclient:', '    running install', '    running build', '    running build_py', '    creating build', '    creating build\\lib.win32-3.7', '    creating build\\lib.win32-3.7\\MySQLdb', '    copying MySQLdb\\__init__.py -> build\\lib.win32-3.7\\MySQLdb', '    copying MySQLdb\\_exceptions.py -> build\\lib.win32-3.7\\MySQLdb', '    copying MySQLdb\\compat.py -> build\\lib.win32-3.7\\MySQLdb', '    copying MySQLdb\\connections.py -> build\\lib.win32-3.7\\MySQLdb', '    copying MySQLdb\\converters.py -> build\\lib.win32-3.7\\MySQLdb', '    copying MySQLdb\\cursors.py -> build\\lib.win32-3.7\\MySQLdb', '    copying MySQLdb\\release.py -> build\\lib.win32-3.7\\MySQLdb', '    copying MySQLdb\\times.py -> build\\lib.win32-3.7\\MySQLdb', '    creating build\\lib.win32-3.7\\MySQLdb\\constants', '    copying MySQLdb\\constants\\__init__.py -> build\\lib.win32-3.7\\MySQLdb\\constants', '    copying MySQLdb\\constants\\CLIENT.py -> build\\lib.win32-3.7\\MySQLdb\\constants', '    copying MySQLdb\\constants\\CR.py -> build\\lib.win32-3.7\\MySQLdb\\constants', '    copying MySQLdb\\constants\\ER.py -> build\\lib.win32-3.7\\MySQLdb\\constants', '    copying MySQLdb\\constants\\FIELD_TYPE.py -> build\\lib.win32-3.7\\MySQLdb\\constants', '    copying MySQLdb\\constants\\FLAG.py -> build\\lib.win32-3.7\\MySQLdb\\constants', '    warning: build_py: byte-compiling is disabled, skipping.', '    ', '    running build_ext', "    building 'MySQLdb._mysql' extension", '    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/', '    ', '    ----------------------------------------']
[pipenv.exceptions.InstallError]: ['Failed building wheel for mysqlclient', 'Command "c:\\users\\kristian.senior\\.virtualenvs\\user_database-avroy6jj\\scripts\\python.exe -u -c "import setuptools, tokenize;__file__=\'C:\\\\Users\\\\KRISTI~1.SEN\\\\AppData\\\\Local\\\\Temp\\\\pip-install-ebs0lxzd\\\\mysqlclient\\\\setup.py\';f=getattr(tokenize, \'open\', open)(__file__);code=f.read().replace(\'\\r\\n\', \'\\n\');f.close();exec(compile(code, __file__, \'exec\'))" install --record C:\\Users\\KRISTI~1.SEN\\AppData\\Local\\Temp\\pip-record-oa9a3r9h\\install-record.txt --single-version-externally-managed --compile --install-headers c:\\users\\kristian.senior\\.virtualenvs\\user_database-avroy6jj\\include\\site\\python3.7\\mysqlclient" failed with error code 1 in C:\\Users\\KRISTI~1.SEN\\AppData\\Local\\Temp\\pip-install-ebs0lxzd\\mysqlclient\\']
ERROR: ERROR: Package installation failed...
     ================================ 0/1 - 00:00:05

1 个答案:

答案 0 :(得分:0)

我只是遇到了同样的问题,并且遇到了这个问题,所以在这里分享我的解决方案:

只需在终端中运行以下命令:

export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"

然后重试,它应该可以正常安装。

某些背景:这里的问题出在'mysqlclient'上,pipenv在安装flask-mysqldb时尝试安装它。正如您从日志中看到的:

  

在安装mysqlclient == 1.4.1时发生错误

尝试直接安装mysqlclient(pipenv install mysqlclient)时,您会收到相同的错误。

发现该错误消息后,您发现它:

  

'ld:找不到用于-lssl的库

不确定这到底是什么意思,但是如果您在上面设置了变量,它将起作用。

来源:https://github.com/brianmario/mysql2/issues/795