错误:mysqlclient

时间:2019-06-20 19:37:30

标签: mysql django python-3.6 psycopg2

我无法'pip install mysqlclient',并且每次尝试都返回错误:'ERROR:mysqlclient的构建轮失败'。就上下文而言,我在macOS Mojave 10.14.5上运行。本文的其余部分假定已经下载了“ python == 3.6”和“ virtualenv”。另外,已经安装了x代码命令行工具(不是我认为很重要)。

要执行的步骤是(从命令行):

  1. 'virtualenv〜/ venv'

    • 输出:

    使用基本前缀'/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6' /Users/usr1/venv/bin/python3.6中的新python可执行文件 还可以在/ Users / usr1 / venv / bin / python中创建可执行文件 安装setuptools,pip,wheel ...完成。”

  2. '源〜/ venv / bin / activate'

  3. 'pip install mysqlclient'

到目前为止,我已经查看并尝试了以下所有操作:

  1. Failed building wheel for mysqlclient

  2. "Failed building wheel for psycopg2" - MacOSX using virtualenv and pip

  3. Failed building wheel for mysql-python

    收集mysqlclient   使用缓存的https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz 收集包的构建轮:mysqlclient   mysqlclient(setup.py)的构建轮...错误   错误:命令/Users/usr1/venv/bin/python3.6 -u -c'import setuptools,tokenize; file ='“'''/ private / var / folders / 2j的完整输出/1qt0_7q96lxbxl2w5kx8r1zr0000gn/T/pip-install-4uobjq_4/mysqlclient/setup.py'"''';f=getattr(tokenize,'“'”'open'“'”',open)(文件 >); code = f.read()。replace(''''“'\ r \ n'”'“','”'“'\ n'”'“'); f.close(); exec(编译(代码,文件,'“'”'exec'“'”')))'bdist_wheel -d / private / var / folders / 2j / 1qt0_7q96lxbxl2w5kx8r1zr0000gn / T / pip-wheel-ehvuw9uv- python标签cp36:   错误:正在运行bdist_wheel   运行构建   运行build_py   创建版本   创建build / lib.macosx-10.13-x86_64-3.6   创建build / lib.macosx-10.13-x86_64-3.6 / MySQLdb   复制MySQLdb / init .py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb   复制MySQLdb / _exceptions.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb   复制MySQLdb / compat.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb   复制MySQLdb / connections.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb   复制MySQLdb / converters.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb   复制MySQLdb / cursors.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb   复制MySQLdb / release.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb   复制MySQLdb / times.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb   创建build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants   复制MySQLdb / constants / init .py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants   复制MySQLdb / constants / CLIENT.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants   复制MySQLdb / constants / CR.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants   复制MySQLdb / constants / ER.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants   复制MySQLdb / constants / FIELD_TYPE.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants   复制MySQLdb / constants / FLAG.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants   运行build_ext   构建'MySQLdb._mysql'扩展   创建build / temp.macosx-10.13-x86_64-3.6   创建build / temp.macosx-10.13-x86_64-3.6 / MySQLdb   clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info =(1,4,2,'post',1 )-D__version __ = 1.4.2.post1 -I / usr / local / Cellar / mysql / 5.7.19 / include / mysql -I / usr / local / Cellar / python / 3.6.5_1 / Frameworks / Python.framework / Versions / 3.6 / include / python3.6m -c MySQLdb / _mysql.c -o build / temp.macosx-10.13-x86_64-3.6 / MySQLdb / _mysql.o   铛-bundle-未定义dynamic_lookup build / temp.macosx-10.13-x86_64-3.6 / MySQLdb / _mysql.o -L / usr / local / Cellar / mysql / 5.7.19 / lib -lmysqlclient -lssl -lcrypto -o build / lib .macosx-10.13-x86_64-3.6 / MySQLdb / _mysql.cpython-36m-darwin.so   ld:找不到-lssl的库   clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)   错误:命令“ clang”失败,退出状态为1


    错误:mysqlclient的构建轮失败   为mysqlclient运行setup.py clean 无法建立mysqlclient 安装收集的软件包:mysqlclient   正在运行setup.py install for mysqlclient ...错误     错误:命令/Users/usr1/venv/bin/python3.6 -u -c'import setuptools,tokenize; file ='“'''/ private / var / folders / 2j的完整输出/1qt0_7q96lxbxl2w5kx8r1zr0000gn/T/pip-install-4uobjq_4/mysqlclient/setup.py'"''';f=getattr(tokenize,'“'”'open'“'”',open)(文件 >); code = f.read()。replace(''''“'\ r \ n'”'“','”'“'\ n'”'“'); f.close(); exec(编译(代码,文件,'“'”'exec'“'”')))'安装--record / private / var / folders / 2j / 1qt0_7q96lxbxl2w5kx8r1zr0000gn / T / pip-record-zvd4oedq / install-record.txt-单一版本-外部管理-编译--install-headers /Users/usr1/venv/bin/../include/site/python3.6/mysqlclient:     错误:正在运行安装     运行构建     运行build_py     创建版本     创建build / lib.macosx-10.13-x86_64-3.6     创建build / lib.macosx-10.13-x86_64-3.6 / MySQLdb     复制MySQLdb / init .py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb     复制MySQLdb / _exceptions.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb     复制MySQLdb / compat.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb     复制MySQLdb / connections.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb     复制MySQLdb / converters.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb     复制MySQLdb / cursors.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb     复制MySQLdb / release.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb     复制MySQLdb / times.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb     创建build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants     复制MySQLdb / constants / init .py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants     复制MySQLdb / constants / CLIENT.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants     复制MySQLdb / constants / CR.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants     复制MySQLdb / constants / ER.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants     复制MySQLdb / constants / FIELD_TYPE.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants     复制MySQLdb / constants / FLAG.py-> build / lib.macosx-10.13-x86_64-3.6 / MySQLdb / constants     运行build_ext     构建'MySQLdb._mysql'扩展     创建build / temp.macosx-10.13-x86_64-3.6     创建build / temp.macosx-10.13-x86_64-3.6 / MySQLdb     clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info =(1,4,2,'post',1 )-D__version __ = 1.4.2.post1 -I / usr / local / Cellar / mysql / 5.7.19 / include / mysql -I / usr / local / Cellar / python / 3.6.5_1 / Frameworks / Python.framework / Versions / 3.6 / include / python3.6m -c MySQLdb / _mysql.c -o build / temp.macosx-10.13-x86_64-3.6 / MySQLdb / _mysql.o     铛-bundle-未定义dynamic_lookup build / temp.macosx-10.13-x86_64-3.6 / MySQLdb / _mysql.o -L / usr / local / Cellar / mysql / 5.7.19 / lib -lmysqlclient -lssl -lcrypto -o build / lib .macosx-10.13-x86_64-3.6 / MySQLdb / _mysql.cpython-36m-darwin.so     ld:找不到-lssl的库     clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)     错误:命令“ clang”失败,退出状态为1     ---------------------------------------- 错误:命令“ /Users/usr1/venv/bin/python3.6 -u -c'import setuptools,tokenize; file ='”'“'/ private / var / folders / 2j / 1qt0_7q96lxbxl2w5kx8r1zr0000gn /T/pip-install-4uobjq_4/mysqlclient/setup.py'"'"';f=getattr(tokenize,'“'”'open'“'”',打开)(文件) ; code = f.read()。replace('“'”'\ r \ n'“'”','“'”'\ n'“'”'); f.close(); exec(compile(代码,文件,'“'”'exec'“'”'')))'安装--record / private / var / folders / 2j / 1qt0_7q96lxbxl2w5kx8r1zr0000gn / T / pip-record-zvd4oedq / install- record.txt-单一版本-外部管理--compile --install-headers /Users/usr1/venv/bin/../include/site/python3.6/mysqlclient失败,错误代码为/ private / var / folders / 2j / 1qt0_7q96lxbxl2w5kx8r1zr0000gn / T / pip-install-4uobjq_4 / mysqlclient /

结论:理想情况下,我希望'pip'可以简单地安装'mysqlclient'。我非常感谢您的帮助。预先感谢。

3 个答案:

答案 0 :(得分:0)

从此处下载mysqlclient.whl Python Extension Package for Windows并使用pip install mysqlclient‑1.4.2‑cp36‑cp36m‑win_amd64.whl

安装

答案 1 :(得分:0)

我在您的错误回复中看到了这一行

ld: library not found for -lssl clang: error: linker command failed with exit code 1

相信我,我花了很长时间才弄清楚上述错误。我已经回答了一个类似的问题,请参考 this 链接。它可能会解决您的问题,

P.S:我对你的帖子发表评论的名气不大,所以发帖是为了回答,抱歉。

答案 2 :(得分:0)

只需要安装开发版的python:

sudo apt-get install python3-dev

ERROR: Failed building wheel for mysqlclient