`pip install flask_mysqldb`由于clang失败:错误:链接器命令失败,退出代码为1

PBa*_*Jen 0 python mysql

我正在尝试将我的烧瓶应用程序与mysql数据库连接。

Python版本:Python 2.7.11

我试图安装flask_mysqldbpip install flask_mysqldb,但我得到这个错误:

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/
Run Code Online (Sandbox Code Playgroud)

任何人都可能知道这是什么问题?

小智 9

如果使用macOS,请尝试xcode-select --install安装命令行工具。如果这不起作用:

1。

brew install openssl
Run Code Online (Sandbox Code Playgroud)

2。

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
Run Code Online (Sandbox Code Playgroud)

  • 找不到OpenSSL开发文件。您告诉构建过程在哪里可以找到它们。 (2认同)