`pip install flask_mysqldb` 由于叮当声失败:错误:链接器命令失败,退出代码为 1 [英] `pip install flask_mysqldb` fails due to clang: error: linker command failed with exit code 1
本文介绍了`pip install flask_mysqldb` 由于叮当声失败:错误:链接器命令失败,退出代码为 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将我的 Flask 应用程序与 mysql 数据库连接起来.
I'm trying to connect my flask app with a mysql db.
Python 版本:Python 2.7.11
Python Version: Python 2.7.11
我正在尝试通过 pip install flask_mysqldb
安装 flask_mysqldb
,但出现此错误:
I'm trying to install flask_mysqldb
by pip install flask_mysqldb
, but I get this error:
Collecting flask_mysqldb
Requirement already satisfied: Flask>=0.10 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from flask_mysqldb) (1.0.2)
Collecting mysqlclient (from flask_mysqldb)
Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz
Requirement already satisfied: itsdangerous>=0.24 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from Flask>=0.10->flask_mysqldb) (0.24)
Requirement already satisfied: Jinja2>=2.10 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from Flask>=0.10->flask_mysqldb) (2.10)
Requirement already satisfied: Werkzeug>=0.14 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from Flask>=0.10->flask_mysqldb) (0.14.1)
Requirement already satisfied: click>=5.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from Flask>=0.10->flask_mysqldb) (6.7)
Requirement already satisfied: MarkupSafe>=0.23 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from Jinja2>=2.10->Flask>=0.10->flask_mysqldb) (1.0)
Building wheels for collected packages: mysqlclient
Running setup.py bdist_wheel for mysqlclient ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/var/folders/k0/j8c755m50dndbzkv7fdtj5hh0000gn/T/pip-install-lffPsc/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 /private/var/folders/k0/j8c755m50dndbzkv7fdtj5hh0000gn/T/pip-wheel-XdyDLe --python-tag cp27:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.6-intel-2.7
copying _mysql_exceptions.py -> build/lib.macosx-10.6-intel-2.7
creating build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
creating build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.6-intel-2.7
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 -I/usr/local/Cellar/mysql/8.0.11/include/mysql -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.6-intel-2.7/_mysql.o
/usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.6-intel-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
Installing collected packages: mysqlclient, flask-mysqldb
Running setup.py install for mysqlclient ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/var/folders/k0/j8c755m50dndbzkv7fdtj5hh0000gn/T/pip-install-lffPsc/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 /private/var/folders/k0/j8c755m50dndbzkv7fdtj5hh0000gn/T/pip-record-fvSl2V/install-record.txt --single-version-externally-managed --compile:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.macosx-10.6-intel-2.7
copying _mysql_exceptions.py -> build/lib.macosx-10.6-intel-2.7
creating build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
creating build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.6-intel-2.7
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 -I/usr/local/Cellar/mysql/8.0.11/include/mysql -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.6-intel-2.7/_mysql.o
/usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.6-intel-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/var/folders/k0/j8c755m50dndbzkv7fdtj5hh0000gn/T/pip-install-lffPsc/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 /private/var/folders/k0/j8c755m50dndbzkv7fdtj5hh0000gn/T/pip-record-fvSl2V/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/k0/j8c755m50dndbzkv7fdtj5hh0000gn/T/pip-install-lffPsc/mysqlclient/
有人可能知道可能是什么问题吗?
Anyone might know what might be the issue?
推荐答案
如果使用 macOS,请尝试 xcode-select --install
安装命令行工具.如果这不起作用:
If using macOS, try xcode-select --install
to install the command-line tools. If this does not work:
1.
brew install openssl
2.
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
这篇关于`pip install flask_mysqldb` 由于叮当声失败:错误:链接器命令失败,退出代码为 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文