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源试试

然后可以安装成功

9b31c49f79b25d2cd060419c95b03435.png

失败2

使用pip install mysqlclient命令安装mysqlclient失败?

安装mysqlclient报错如下

3bf2fb922521d518166bdcc21e7c22f9.png

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导入问题

e05b52d3e15f389a342b61118c9f6444.png

在包安装的时候,会默认在包下的路径,error

6714da2893421ecb6840a6c582c34b7d.png

3825f66d00c81bec8ba0a8cba12a5706.png

---恢复内容结束---

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/536931.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

我的这套VuePress主题你熟悉吧

最近熬了很多个夜晚, 踩坑无数, 终于写出了用VuePress驱动的主题. 只需体验三分钟,你就会跟我一样,爱上这款主题. vuepress-theme-indigo-material, 已经发布到npm, 请客官享用~~ 介绍 vuepress-theme-indigo-material 的原主题是hexo-theme-indigo, git…

两年Java工作经验应该会些什么技术

*************************************优雅的分割线 ********************************** 分享一波:程序员赚外快-必看的巅峰干货 如果以上内容对你觉得有用,并想获取更多的赚钱方式和免费的技术教程 请关注微信公众号:HB荷包 一个能让你学习技术和赚钱方法的公众号,持续更…

centos 6 mysql 5.7.13 编译安装_Centos 6.5 下面 源码编译 安装 Mysql 5.7.13

安装软件依赖包yum -y install gcc gcc-c ncurses ncurses-devel cmake下载软件包cd /usr/local/srcwget https://downloads.mysql.com/archives/get/file/mysql-5.7.13.tar.gz --no-check-certificate下载 boost 库,MySQL 5.7.5 开始Boost库是必需的cd /usr/loca…

LeetCode 237. 删除链表中的节点(Python3)

题目: 请编写一个函数,使其可以删除某个链表中给定的(非末尾)节点,你将只被给定要求被删除的节点。 现有一个链表 -- head [4,5,1,9],它可以表示为: 示例 1: 输入: head [4,5,1,9], node 5 输出: [4,1,9…

使用Uniapp随手记录知识点

使用uniapp随手记录知识点 1 组件内置组件扩展组件 2 vuex状态管理使用流程mapState 辅助函数gettersMutation 1 组件 内置组件 内置组件内主要包含一些基础的view button video scroll-view等内置基础组件,满足基础场景 扩展组件 扩展组件是uniapp封装了一些成…

一年Java经验应该会些什么

*************************************优雅的分割线 ********************************** 分享一波:程序员赚外快-必看的巅峰干货 如果以上内容对你觉得有用,并想获取更多的赚钱方式和免费的技术教程 请关注微信公众号:HB荷包 一个能让你学习技术和赚钱方法的公众号,持续更…

mysql查询各类课程的总学分_基于jsp+mysql的JSP学生选课信息管理系统

运行环境: 最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。IDE环境: Eclipse,Myeclipse,IDEA都可以硬件环境: windows 7/8/10 2G内存以上(推荐4G,4G以上更好)可以实现: 学生,教师角色的…

80端口占用分析

SQL Server 2008 里面的组件——SQL Server Reporting Services (MSSQLSERVER)。是 SQL Server 的日志系统,就是他好端端的突然占用了80端口,而且对于普通人来讲,这个组件的作用没啥用,关掉也是节约资源。 关闭服务 ReportServer …

三年java经验应该会什么?

*************************************优雅的分割线 ********************************** 分享一波:程序员赚外快-必看的巅峰干货 如果以上内容对你觉得有用,并想获取更多的赚钱方式和免费的技术教程 请关注微信公众号:HB荷包 一个能让你学习技术和赚钱方法的公众号,持续更…

python call agilent com_PyVISA通过RS232(USB)与安捷伦34970A通信时出现超时错误

这是我第一次尝试使用Pyvisa,以便使用RS232连接(使用USB端口)与Agilent 34970A进行通信。在这就是发生在我身上的事情,插入基本的第一行:IN: import visaIN: rmvisa.ResourceManager()IN: print rm.list_resources()(uASRL4::INSTR,)IN: inst…

python加法运算符可以用来连接字符串并生成新字符串_中国大学MOOCPython语言入门网课答案...

中国大学MOOCPython语言入门网课答案表达式int(40.5)的值为____________。表达式160.5的值为____________________。python程序只能使用源代码进行运行,不能打包成可执行文件。python语句list(range(1,10,3))执行结果为___________________。pip命令也支持扩展名为.…

全是满满的技术文档

*************************************话不多说-先上教程 ********************************** 完整躺赚教程(不需任何技术,照做就能赚钱):点击此处获取 提取码&#xff1a;6666 被动收入教程(需要一定的技术,会搭建服务器,会发布项目<教程里面会教你>):点击此处获取 提…

JavaScript面试的完美指南(开发者视角)

2019独角兽企业重金招聘Python工程师标准>>> 摘要&#xff1a; 面试季手册。 原文&#xff1a;javascript 面试的完美指南(开发者视角)作者&#xff1a;前端小智Fundebug经授权转载&#xff0c;版权归原作者所有。 为了说明 JS 面试的复杂性&#xff0c;首先&#x…

电脑上mysql数据库无法登录_无法远程登入MySQL数据库的几种解决办法MySQL综合 -电脑资料...

方法一&#xff1a;尝试用MySQL Adminstrator GUI Tool登入MySQL Server&#xff0c;Server却回复错误讯息&#xff1a;Host 60-248-32-13.HINET-IP.hinet.net is not allowed to connect to thisMySQL server这个是因为权限的问题&#xff0c;处理方式如下&#xff1a;shell&g…

如何优化 App 的启动耗时?

原文&#xff1a;iOS面试题大全 iOS 的 App 启动主要分为以下步骤&#xff1a; 打开 App&#xff0c;系统内核进行初始化跳转到 dyld 执行。这个过程包括这些步骤&#xff1a;1&#xff09;分配虚拟内存空间&#xff1b;2&#xff09;fork 进程&#xff1b;3&#xff09;加载 M…

windows qt 不能debug_linux配置vlc-qt

vlc-qt 是基于vlc库&#xff0c;用于开发音频视频应用&#xff0c;性能优秀。vlc-qt/vlc-qt​github.com使用vlc-qt首先需要编译vlc-qt &#xff08;windows可以下载使用编译好的&#xff0c;但是只能用在release模式&#xff09;&#xff08;在windows系统中&#xff09;使用w…

idou老师教你学Istio 27:解读Mixer Report流程

1、概述 Mixer是Istio的核心组件&#xff0c;提供了遥测数据收集的功能&#xff0c;能够实时采集服务的请求状态等信息&#xff0c;以达到监控服务状态目的。 1.1 核心功能 •前置检查&#xff08;Check&#xff09;&#xff1a;某服务接收并响应外部请求前&#xff0c;先通过E…

mysql删除密码代码_mysql 用户新建、受权、删除、密码修改

mysql 用户新建、授权、删除、密码修改首先要声明一下&#xff1a;一般情况下&#xff0c;修改MySQL密码&#xff0c;授权&#xff0c;是需要有mysql里的root权限的。注&#xff1a;本操作是在WIN命令提示符下&#xff0c;phpMyAdmin同样适用。用户&#xff1a;phplamp 用户数…

KindEditor 上传漏洞致近百个党政机关网站遭植入

开发四年只会写业务代码&#xff0c;分布式高并发都不会还做程序员&#xff1f; >>> 2月21日消息&#xff0c;近日&#xff0c;安恒明鉴网站安全监测平台和应急响应中心监测发现近百起党政机关网站被植入色情广告页面&#xff0c;分析发现被植入色情广告页面的网站都…

php mysql登陆页面完整代码_求助:PHP实现登陆注册的代码是什么啊(主要是数据库那块)?...

思路&#xff1a;注册&#xff1a;获取前台表单数据->数据库连接->判断数据是否存在&#xff0c;存在输出提示&#xff0c;不存在则向数据库插入表单传来的值->如果sql执行失败输出错误&#xff0c;成功功输出注册成功登陆&#xff1a;获取前台表单数据->数据库连接…