linux mysql python包_03_mysql-python模块, linux环境下python2,python3的
---恢复内容开始---
1、Python2 正常
[root@IP ~]#pip install mysql-python
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: mysql-python in /usr/lib64/python2.7/site-packages (1.2.5)#测试
[root@IP ~]#python2
Python 2.7.5 (default, Aug 7 2019, 00:51:29)
[GCC4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type"help", "copyright", "credits" or "license" formore information.>>> importMySQLdb>>>
有时候,上面的包安装好了,导入失败
另外的
[root@IP ~]#pip install mysqlclient
[root@IP~]#pip list
mysqlclient 1.4.6
#成功
[root@IP ~]#python
Python 2.7.5 (default, Aug 7 2019, 00:51:29)
[GCC4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type"help", "copyright", "credits" or "license" formore information.>>> importMySQLdb>>>
2、说明
python2中支持 MySQLdb
python3为PyMySQL或
python3中mysqldb不再支持,包括mysql-python是安装不上的。
转为Pymysql
命令:
pip3 install PyMySQL
使用及安装参考链接:
3、python3安装PyMySQL
[root@IP mysqlclient-1.4.6]#pip3 install PyMySQL
[root@IP mysqlclient-1.4.6]#python3
Python 3.6.8 (default, Apr 25 2019, 21:02:35)
[GCC4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type"help", "copyright", "credits" or "license" formore information.>>> import pymysql
4、python3 安装 mysqlclient
失败1
[root@localhost ~]#pip3 install mysqlclient
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz
Complete outputfromcommand python setup.py egg_info:/bin/sh: mysql_config: command notfound/bin/sh: mariadb_config: command notfound/bin/sh: mysql_config: command notfound
Traceback (most recent call last):
File"", line 1, in File"/tmp/pip-build-bpt1pa2k/mysqlclient/setup.py", line 16, in metadata, options=get_config()
File"/tmp/pip-build-bpt1pa2k/mysqlclient/setup_posix.py", line 61, inget_config
libs= mysql_config("libs")
File"/tmp/pip-build-bpt1pa2k/mysqlclient/setup_posix.py", line 29, inmysql_configraise EnvironmentError("%s not found" %(_mysql_config_path,))
OSError: mysql_confignotfound----------------------------------------Command"python setup.py egg_info" failed with error code 1 in /tmp/pip-build-bpt1pa2k/mysqlclient/
按照网上
更新pip3 和 setuptools
[root@localhost ~]#pip3 install --upgrade setuptools
[root@localhost ~]#python3 -m pip install --upgrade pip
继续失败
[root@localhost ~]#pip3 install mysqlclient
Traceback (most recent call last):
File"/usr/bin/pip3", line 16, in sys.exit(main())
TypeError:'module' object is not callable
安装mysql依赖
yum install mysql-devel gcc gcc-devel python-devel
继续安装
[root@localhost ~/mysqlclient-1.4.6]#python3 setup.py install
[Errno 2] No such file ordirectory:'/usr/local/lib64/python3.6/site-packages/test-easy-install-35198.write-test'The installation directory you specified (via--install-dir, --prefix, orthe distutils default setting) was:/usr/local/lib64/python3.6/site-packages/This directory doesnot currently exist. Please create it and try again, orchoose a different installation directory (using the-d or --install-dir
option).
报错
创建该目录
失败1.1
deepin失败
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File"setup.py", line 16, in metadata, options=get_config()
File"/home/redhat/Desktop/pycharmProject/base-api/mysqlclient-1.4.6/setup_posix.py", line 61, inget_config
libs= mysql_config("libs")
File"/home/redhat/Desktop/pycharmProject/base-api/mysqlclient-1.4.6/setup_posix.py", line 29, inmysql_config
raise EnvironmentError("%s not found" %(_mysql_config_path,))
OSError: mysql_config not found
安装这个,找不到,
sudo apt-get install libmysqlclient-dev
更新apt源试试
然后可以安装成功
失败2
使用pip install mysqlclient命令安装mysqlclient失败?
安装mysqlclient报错如下
1、下载本地whl,安装
blog:https://blog.csdn.net/cn_1937/article/details/81533544
https://blog.csdn.net/liuweiyuxiang/article/details/80666773
#下载包
[root@IP mysqlclient-1.4.6]#wget
https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz#解压
[root@IP ~]#tar xvf mysqlclient-1.4.6.tar.gz
#安装保存 缺少gcc
[root@IP mysqlclient-1.4.6]#python3 setup.py install
MySQLdb/_mysql.c:38:20: fatal error: Python.h: No such file ordirectory#include "Python.h"
^compilation terminated.
error: command'gcc' failed with exit status 1
2、安装python3-devel
#安装成功依赖
[root@IP mysqlclient-1.4.6]#yum install python3-devel
重装成功
[root@IP mysqlclient-1.4.6]#python3 setup.py install
或者
[root@IP mysqlclient-1.4.6]#pip3 install mysqlclient
导入有问题
#导入有问题
[root@IP mysqlclient-1.4.6]#python3
Python 3.6.8 (default, Aug 7 2019, 17:28:10)
[GCC4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type"help", "copyright", "credits" or "license" formore information.>>> importMySQLdb
Traceback (most recent call last):
File"", line 1, in File"/root/mysqlclient-1.4.6/MySQLdb/__init__.py", line 18, in
from . import_mysql
ImportError: cannotimport name '_mysql'
3、MySQLdb导入问题
在包安装的时候,会默认在包下的路径,error
---恢复内容结束---
linux mysql python包_03_mysql-python模块, linux环境下python2,python3的相关推荐
- python 模块 导入机制 模块搜索 Python包 发布python模块或程序
python 模块 python模块:以.py结尾的代码文件. 顶层文件: 程序执行入口 模块文件1 模块文件2 模块文件3 在python中一 ...
- linux环境下安装python3以及安装cx_Oracle模块需要注意的事项
linux环境下安装python3以及安装cx_Oracle模块需要注意的事项 python3的安装 1. 首先安装python3之前首先要安装python所依赖的环境 yum install gcc ...
- MYSQL 5.7 解压版 windows 环境下安装
MYSQL 5.7 解压版 windows 环境下安装 1.下载MYSQL 2.下载完成后,放入要部署目录,解压. 3.新建 my.ini 文件 data 子文件夹千万不要自己建,否则后续启动会报错 ...
- 如何在源码包编译安装的 LEMP 环境下开启 OpenSSL 功能
如何在源码包编译安装的 LEMP 环境下开启 OpenSSL 功能 Hello,大家好!我是--邪恶君子! 今天,给大家分享一下解决源码包编译安装 LEMP 环境下开启 OpenSSL 功能问题的过程 ...
- linux python 升级脚本,Linux环境下python2.7.6升级python3.5.2
需求 Linux环境下有些是自带的Python2版本有时是刚安装号的Python其他版本,当新版本出来的时候,在开发的时候往往会选择新版本的软件进行安装. 原因 在开发的时候选用新版本的软件进行安装的 ...
- python包numpy_NumPy Python科学计算软件包的终极指南
python包numpy NumPy (pronounced "numb pie") is one of the most important packages to grasp ...
- linux mysql清除缓存_转载-清除Linux中MySQL的使用痕迹~/.mysql_history
背景:我们在管理MySQL server的时候,常常使用mysql命令行工具连接MySQL server进行操作,此时我们可以像shell命令行一样,按向上的方向键, mysql会给出我们最近执行的S ...
- python 包用法,Python包的使用
包对应的是一个目录而不是一个源文件,包目录下一定要存在一个名为 __init__.py 的文件.如我们可以创建下面的目录结构: $ tree pkgDemo1/ pkgDemo1/ └── __ini ...
- linux mysql 文件夹权限_找到linux文件夹
FineReport关于Linux下字体乱码终极解决方案 1:在windows下找到系统使用到的字体,这里以楷体举例 •到c盘的windows文件夹的Fonts文件夹里面存放了windows中用到的所 ...
- linux命令下怎么保存python_Linux 环境下安装 Python3 的操作方法
作者:肖辉,武汉大学硕士在读 博客地址:https://blog.csdn.net/xiaohuimary Github: https://github.com/xiaohui96 Linux 下 P ...
最新文章
- python什么时候用框架_Python 中三大框架各自的应用场景
- 微波人体感应模块 24G 24.125g 感应开关微波传感器模块
- 《重构,改善既有代码的设计》读书笔记
- python windows下的file()
- Oracle-存储过程实现更改用户密码
- AFN post的数据编码格式问题
- python 浏览器,轻量级Python Web浏览器
- Oracle数据库的三种标准的备份方法
- 微信小程序黑客马拉松即将开始,来做最酷的 Mini Program Creators! 1
- 采集练习(五) php 获得chrome扩展 微度新标签页 下的云壁纸(主要是美女壁纸)
- 票据纸张尺寸对照表_纸张小科普 | 白卡纸
- 内存压力测试工具Memtester
- php 分页样式css样式,thinkphp5分页CSS样式代码
- websocket客户端与TCP服务器连接异常
- 中国移动通信互联网短信网关接口协议CMPP2.0(普通文本短信、二进制数据短信)
- 【文献阅读】Optimistic Bull or Pessimistic Bear: Adaptive Deep Reinforcement Learning for Stock Portfolio
- 【React】项目中组件化使用svg格式的图片
- InZiv 为 MicroLED 显示检测技术筹集 1000 万美元
- UE4制作插件的插件神器pluginCreator
- 软件需求分析与IT创新
热门文章
- Android渠道包自动发布市场,Android Gradle实现打包指定渠道后自动上传到fir
- 强行终止python_中国的真实离婚率:一点也不高,反而低的惊人 | 用python计算离婚率...
- C\C++中声明与定义的区别
- linux训练python出现killed_Linux 查看进程被杀死的详情
- centos odbc mysql_Centos下安装并配置ODBC连接MySQL 【转】
- gradle 查看依赖类库版本_Android studio中查看依赖的第三方库的历史版本和最新版本...
- 存储器是计算机的记忆装置,存储器(Memory)
- 二级MS Office公共基础知识错题本(1)
- 【Java从入门到头秃专栏 】(二) 注释 数据类型 变量 常量 关键字 标识符 运算符 输入输出
- Linux namespace之:network namespace