前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >macOS使用django安装mysqlclient遇到的问题(mysqlclient 1.3.3 or newer is required)

macOS使用django安装mysqlclient遇到的问题(mysqlclient 1.3.3 or newer is required)

作者头像
老潘
修改2018-06-22 12:01:59
1.6K0
修改2018-06-22 12:01:59
举报
有两个月没有碰django了,没想到一下从11.3升级到了2.0。django框架团队真的是很用心。

最近需要使用django搭建一个网站,使用的数据库是mysql。 mac电脑里面已经安装好了mysql-5.7-community。 之前使用的python和mysql的链接模块是Pymysql,使用django-11.3版本的时候没有需要问题。但是重新更新了django到2.0,下载好之前的配置后(requests),运行程序发现这个问题:

mysqlclient 1.3.3 or newer is required; you have 0.7.11.None

好吧,连之前的Pymysql都不能用了,于是进行安装mysqlclient。 使用pip进行安装:

pip install mysqlclient

并没有那么顺利,立马进行报错:

sh: mysql_config: command not found
Traceback (most recent call last):
  File "setup.py", line 15, in <module>
  ...

原来是没有找到mysql_config命令,那就进行添加吧:

(my-virtual-env-3.6.2) guoyanzongdeMacBook-Pro:Web_Assignment oldpan$ PATH="$PATH":/usr/local/mysql/bin

(my-virtual-env-3.6.2) guoyanzongdeMacBook-Pro:Web_Assignment oldpan$ mysql_config
Usage: /usr/local/mysql/bin/mysql_config [OPTIONS]
Compiler: Clang 8.1.0
Options:
        --cflags         [-I/usr/local/mysql/include ]
        --cxxflags       [-I/usr/local/mysql/include ]
        --include        [-I/usr/local/mysql/include]
        --libs           [-L/usr/local/mysql/lib -lmysqlclient ]
        --libs_r         [-L/usr/local/mysql/lib -lmysqlclient ]
        --plugindir      [/usr/local/mysql/lib/plugin]
        --socket         [/tmp/mysql.sock]
        --port           [0]
        --version        [5.7.19]
        --libmysqld-libs [-L/usr/local/mysql/lib -lmysqld ]
        --variable=VAR   VAR is one of:
                pkgincludedir [/usr/local/mysql/include]
                pkglibdir     [/usr/local/mysql/lib]
                plugindir     [/usr/local/mysql/lib/plugin]

好了,mysql_config能用了,接下来进行安装吧:

(my-virtual-env-3.6.2) guoyanzongdeMacBook-Pro:Web_Assignment oldpan$ pip install mysqlclient-1.3.12.tar.gz 
Processing ./mysqlclient-1.3.12.tar.gz
Building wheels for collected packages: mysqlclient
  Running setup.py bdist_wheel for mysqlclient ... error
  Complete output from command /usr/local/opt/pyenv/versions/3.6.2/envs/my-virtual-env-3.6.2/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/m7/1w3636y53qd6k5z6f1hzqhpc0000gn/T/pip-giyw6g30-build/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 /var/folders/m7/1w3636y53qd6k5z6f1hzqhpc0000gn/T/tmpj4_ingaepip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.12-x86_64-3.6
  copying _mysql_exceptions.py -> build/lib.macosx-10.12-x86_64-3.6
  creating build/lib.macosx-10.12-x86_64-3.6/MySQLdb
  copying MySQLdb/__init__.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
  copying MySQLdb/compat.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
  copying MySQLdb/connections.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
  copying MySQLdb/converters.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
  copying MySQLdb/cursors.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
  copying MySQLdb/release.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
  copying MySQLdb/times.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
  creating build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/CR.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/ER.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
  running build_ext
  building '_mysql' extension
  creating build/temp.macosx-10.12-x86_64-3.6
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/local/mysql/include -I/usr/local/opt/pyenv/versions/3.6.2/include/python3.6m -c _mysql.c -o build/temp.macosx-10.12-x86_64-3.6/_mysql.o
  xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

又遇到了问题,经查询是没有安装xcode工具: 打开mac的终端:

xcode-select --install

过了一两分钟后,安装好了,现在再进行安装mysqlclient:

(my-virtual-env-3.6.2) guoyanzongdeMacBook-Pro:Web_Assignment oldpan$ pip install mysqlclient-1.3.12.tar.gz 
Processing ./mysqlclient-1.3.12.tar.gz
Building wheels for collected packages: mysqlclient
  Running setup.py bdist_wheel for mysqlclient ... done
  Stored in directory: /Users/oldpan/Library/Caches/pip/wheels/d1/94/21/97409904f278ca3331b447b448a3e90757b24aa72ddc8e22f1
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.3.12

终于安装好了!

参考资料: 1、http://blog.csdn.net/kedongjun/article/details/51470506 2、http://blog.csdn.net/u014642465/article/details/73890308 3、https://www.cnblogs.com/roystime/p/6920489.html 4、https://www.cnblogs.com/njj10/p/7676123.html

此文由腾讯云爬虫爬取,文章来源于Oldpan博客

欢迎关注Oldpan博客公众号,持续酝酿深度学习质量文:

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017年12月9日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 有两个月没有碰django了,没想到一下从11.3升级到了2.0。django框架团队真的是很用心。
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档