CentOS7使用pip安装mysql-python出错解决方案
2016-09-14 00:00
375 查看
具体错误:
上面的错误是由于缺少mysql_config文件导致,查看下mysql_config文件是否存在
果然mysql_config没有找到,是因为缺少mysql-devel,导致mysql_config丢失,安装mysql-devel即可。
若提示错误应该是MySQL的源存在问题,安装MySQL的源即可,具体见CentOS7编译安装MySQL5.7之后安装mysql-devel出错解决方案
mysql-devel安装成功之后,查看mysql_config是否存在
在/usr/bin/mysql_config已经存在,使用pip安装mysql-python即可
接下来我们就可以使用python操作MySQL数据库了
[root@localhost liuyuantao]# pip install mysql-python Collecting mysql-python Downloading MySQL-python-1.2.5.zip (108kB) 100% |████████████████████████████████| 112kB 77kB/s Complete output from command python setup.py egg_info: sh: mysql_config: command not found Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-7Pn8K6/mysql-python/setup.py", line 17, in <module> metadata, options = get_config() File "setup_posix.py", line 43, in get_config libs = mysql_config("libs_r") File "setup_posix.py", line 25, in mysql_config raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-7Pn8K6/mysql-python/
上面的错误是由于缺少mysql_config文件导致,查看下mysql_config文件是否存在
[root@localhost liuyuantao]# find / -name mysql_config find: ‘/proc/5155’: No such file or directory find: ‘/run/user/1000/gvfs’: Permission denied
果然mysql_config没有找到,是因为缺少mysql-devel,导致mysql_config丢失,安装mysql-devel即可。
yum install mysql-devel
若提示错误应该是MySQL的源存在问题,安装MySQL的源即可,具体见CentOS7编译安装MySQL5.7之后安装mysql-devel出错解决方案
mysql-devel安装成功之后,查看mysql_config是否存在
[root@localhost liuyuantao]# find / -name mysql_config find: ‘/run/user/1000/gvfs’: Permission denied /usr/bin/mysql_config
在/usr/bin/mysql_config已经存在,使用pip安装mysql-python即可
root@localhost liuyuantao]# pip install mysql-python Collecting mysql-python Using cached MySQL-python-1.2.5.zip Building wheels for collected packages: mysql-python Running setup.py bdist_wheel for mysql-python ... done Stored in directory: /root/.cache/pip/wheels/38/a3/89/ec87e092cfb38450fc91a62562055231deb0049a029054dc62 Successfully built mysql-python Installing collected packages: mysql-python Successfully installed mysql-python-1.2.5
接下来我们就可以使用python操作MySQL数据库了
[root@localhost liuyuantao]# python Python 2.7.5 (default, Aug 18 2016, 15:58:25) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import MySQLdb >>> dir(MySQLdb) ['BINARY', 'Binary', 'Connect', 'Connection', 'DATE', 'DATETIME', 'DBAPISet', 'DataError', 'DatabaseError', 'Date', 'DateFromTicks', 'Error', 'FIELD_TYPE', 'IntegrityError', 'InterfaceError', 'InternalError', 'MySQLError', 'NULL', 'NUMBER', 'NotSupportedError', 'OperationalError', 'ProgrammingError', 'ROWID', 'STRING', 'TIME', 'TIMESTAMP', 'Time', 'TimeFromTicks', 'Timestamp', 'TimestampFromTicks', 'Warning', '__all__', '__author__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__revision__', '__version__', '_mysql', 'apilevel', 'connect', 'connection', 'constants', 'debug', 'escape', 'escape_dict', 'escape_sequence', 'escape_string', 'get_client_info', 'paramstyle', 'release', 'result', 'server_end', 'server_init', 'string_literal', 'test_DBAPISet_set_equality', 'test_DBAPISet_set_equality_membership', 'test_DBAPISet_set_inequality', 'test_DBAPISet_set_inequality_membership', 'thread_safe', 'threadsafety', 'times', 'version_info'] >>> MySQLdb.version_info (1, 2, 5, 'final', 1) >>>
相关文章推荐
- Ubuntu pip 安装 mysql-python包出错
- Windows系统下pip安装Python库出错的解决方案
- centos7 使用pip安装python-mysqldb模块出现的问题:
- 使用sudo pip install 安装python包出错的解决方法
- Windows环境下Python使用pip安装部分包出现错误的解决方案
- 使用pip安装MySQL-python模块
- python3的安装过程,以及使用pip3安装出错,提示错误找不到SSL
- centos7 安装python pip 出错
- Windows使用pip安装MySQL-python报错fatal error C1083: Cannot open include file: 'config-win.h'
- Python 3.6.4 / win10 使用pip安装keras时遇到依赖的PyYAML安装出错
- python基础===Windows环境下使用pip install 安装出错"Cannot unpack file"解决办法
- centos 使用pip安装mysql-python
- CentOS7上 pip install MySQL-python 安装失败(error: command 'gcc' failed with exit status 1)的解决办法
- 【Python】pip安装scrapy、mysqlclient出错的解决方法
- [Tips]使用 pip v1.5 安装 MySQL Connector/Python
- 解决Ubuntu pip 安装 mysql-python包出错的问题
- Python: Windows下使用pip安装库出错:Microsoft Visual C++ 9.0 is required < Unable to find vcvarsall.bat
- python 使用 pip安装mysql-python模块
- CentOS7编译安装MySQL5.7之后安装mysql-devel出错解决方案
- pip安装mysql-python出错的解决方法