macos python安装mysqlapi集合
2024-08-24 15:58:21
记录一下,接了一个python2 django1.x的项目,很老了导致很多扩展无法安装
os version:macos catalina
python version: 2.7.18
而django后端使用sqllite以外需要对应客户端引擎,而安装时编译依赖C客户端即实际mysql组件。
使用的数据库后端。 内建的数据库后端有:
'django.db.backends.postgresql'
'django.db.backends.mysql'
'django.db.backends.sqlite3'
'django.db.backends.oracle'
并且修改配置实例
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'USER': 'mydatabaseuser',
'NAME': 'mydatabase',
'TEST': {
'NAME': 'mytestdatabase',
},
},
}
brew unlink mysql
error: command 'gcc' failed with exit status 1
creating build/temp.macosx-10.9-x86_64-2.7
gcc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -g -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql@5.7/5.7.32/include/mysql -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.9-x86_64-2.7/_mysql.o
gcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-2.7/_mysql.o -L/usr/local/Cellar/mysql@5.7/5.7.32/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.9-x86_64-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 'gcc' failed with exit status 1
解决方法:
# Required for mysqlclient, see brew info openssl
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
pip install MySQL-python
Reference:not-found-for-lssl
my_config.h file not found
creating build/temp.macosx-10.9-x86_64-2.7
gcc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -g -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/8.0.23_1/include/mysql -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.9-x86_64-2.7/_mysql.o
_mysql.c:44:10: fatal error: 'my_config.h' file not found
#include "my_config.h"
^~~~~~~~~~~~~
1 error generated.
error: command 'gcc' failed with exit status 1
解决:网上找了很多版本均无法解决,最后发现实际上与linux处理思路是一样的。
brew install mysql # 可以加版本 如 brew install mysq@5.7
brew unlink mysql
brew install mysql-connector-c # 这个是客户端
ln -snvf /usr/local/Cellar/mysql\@5.7/5.7.32/bin/mysql_config /usr/local/bin/ # 做个软连接,位置可能不一致
sed -i -e 's/libs="$libs -l "/libs="$libs -lmysqlclient -lssl -lcrypto"/g' /usr/local/bin/mysql_config
pip install MySQL-python
sh: mysql_config: command not found
sh: mysql_config: command not found
这个与上面类似,可以看到也是在PATH中找mysql_config
最新文章
- Spring5:@Autowired注解、@Resource注解和@Service注解
- Asp.net Core 通过 Ef Core 访问、管理Mysql
- Prince2七大流程之项目准备
- HDU 2222 ----AC自动机
- maya 操作自我整理(二)
- android开发之broadcast学习笔记 分类: android 学习笔记 2015-07-19 16:33 32人阅读 评论(0) 收藏
- 开发Nginx模块
- DelphiXe5中的双向绑定(使用使用TBindScope和TBindExpression,并覆盖AfterConstruction函数)
- Fiddler教程【转】
- 使用基于Android网络通信的OkHttp库实现Get和Post方式简单操作服务器JSON格式数据
- linux的常用命令介绍
- [leetcode](4.21)4. 有效子数组的数目
- Spring中EmptyResultDataAccessException异常产生的原理及处理方法
- C#字节图片互转、字节转换图片、图片转换字节、byte[]转换图片、图片转换成byte[]
- Sql Server 中将由逗号“,”分割的一个字符串转换为一个表集,并应用到 in 条件中
- python3 day01 大纲
- 32网络通信之Poll模型
- 【转载】 从ACM会议看中国大陆计算机科学与国外的差距
- BZOJ2743 HEOI2012采花(离线+树状数组)
- mysq对存在null值的字段排序
热门文章
- greenplum6.14、GPCC6.4安装详解
- 导出目录的JS代码,与目录的三级标题测试
- Spring Cloud 升级之路 - 2020.0.x - 2. 使用 Undertow 作为我们的 Web 服务容器
- Java8中的默认方法
- oo第二单元——多线程魔鬼电梯
- Go+gRPC-Gateway(V2) 微服务实战,小程序登录鉴权服务(五):鉴权 gRPC-Interceptor 拦截器实战
- TypeScript在React项目中的使用总结
- 6. Mybatis Parameters
- IP Networks UVA - 1590
- 一款轻量级的声明式http调用工具!