1

尝试使用 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
4

1 回答 1

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

于 2019-10-03T22:27:57.107 回答