`pip install\u mysqldb`由于叮当声而失败:错误:链接器命令失败,退出代码为1

6tdlim6h  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(337)

我正在尝试将我的flask应用程序连接到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/

谁都知道问题出在哪里?

pobjuy32

pobjuy321#

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

brew install openssl

2

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

相关问题