fedora 安装python mysql

如果你服务器环境允许yum,安装MySQL-python模块就很简单了。

如果直接安装不行,先

安装MySQL-devel后正常运行

yum install mysql-devel

yum install MySQL-python -y

1

yum install MySQL-python -y

 当然也可以源码安装该模块

首先安装 setuptools,下载源代码包:

wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
解压后

python setup.py build
python setup.py install

1

2

3

4

5

wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz

解压后

python setup.py build

python setup.py install

然后安装一些扩展库

yum -y install rpm-build gcc-c++ mysql-devel python-devel

1

yum -y install rpm-build gcc-c++ mysql-devel python-devel

最后安装MySQL-python

下载源代码包:
wget http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz
解压进入安装目录。
编辑 site.cfg ,把 mysql_config 那一行取消注释,并改为:
mysql_config = /usr/lib64/mysql/mysql_config (根据自己mysql安装位置定义)

python setup.py build
python setup.py install

1

2

3

4

5

6

7

8

下载源代码包:

wget http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz

解压进入安装目录。

编辑 site.cfg ,把 mysql_config 那一行取消注释,并改为:

mysql_config = /usr/lib64/mysql/mysql_config  (根据自己mysql安装位置定义)

python setup.py build

python setup.py install

测试安装

[root@woyoo:/tmp/MySQL-python-1.2.3]# python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
/usr/lib64/python2.6/site-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/lib64/python2.6/site-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg/_mysql.pyc, but /tmp/MySQL-python-1.2.3 is being added to sys.path
>>>

1

2

3

4

5

6

7

[root@woyoo:/tmp/MySQL-python-1.2.3]# python

Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import MySQLdb

/usr/lib64/python2.6/site-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/lib64/python2.6/site-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg/_mysql.pyc, but /tmp/MySQL-python-1.2.3 is being added to sys.path

>>>

报出一大堆警告信息,解决办法:删除MySQL-python源目录,再测试一下:

时间: 2024-12-27 23:07:37

fedora 安装python mysql的相关文章

Linux下安装python,mysql

linux 安装Python3 1.python下载 请在终端输入如下命令: cd /home wget http://cdn.npm.taobao.org/dist/python/3.6.5/Python-3.6.5.tgz 说明:这句话的作用主要是用wget软件(初学者请自行了解次软件,以后会经常用到)从一个指定的URL下载文件.其格式为: wget 空格 URL地址.而下载目录就是当前目录,所以需要cd到你需要放置下载文件的地方. 2.解压Python3安装文件 请在终端输入如下命令: t

源码包安装(Python mysql redis)

一  源码包安装 (1)python3.6源码包安装 ./configure ------> 定制功能 make make install mysql 源码包 cmake make make install (2) redis 源码包安装 make 修改环境变量 vim /etc/profile 添加以下一行: export PATH=/opt/redis-3.2.10/src:$PATH 生效配置 source /etc/profile (3) 让python链接redis unzip red

ubuntu 安装python mysql模块

Installation Starting with a vanilla Lucid install , install pip and upgrade to the latest version: apt-get install python-pip pip install -U pip Next, install the required development packages: apt-get install python-dev libmysqlclient-dev then /usr

ubuntu 启动MySql和安装python的MySQLdb模块

ubuntu一般会自己预安装mysql,你只需 /etc/init.d/mysql start|stop|restart|reload|force-reload|status  命令便可以实现mysql的启动,停止重启等等. 当然也可以检验的ubuntu是否已经安装了mysql. 起先我是用pip安装MySQLdb的,然而没装成,之后我就这样安装 sudo apt-get install python-mysqldb 打开python解释器输入 import MySQLdb 没报错.ok 推荐:

_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h':问题的解决 mysql安装python

在win7下安装了Python后,想安装python-MySQL,使用pip安装出现如下问题: >pip install MySQL-python _mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory error: command '"C:\Users\fnngj\AppData\Local\Programs\Common\Microsoft

linux下安装python、scrapy、redis、mysql

今天给线上服务器装爬虫环境,随便记录下安装过程,网上有很多类似的安装过程,我只是整理+验证,希望对需要安装的人有帮助 安装python 安装python wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz tar zxvf Python-2.7.11.tgz cd Python-2.7.11 ./configure --prefix=/usr/local make && make altinstall 检查Pyth

linux 安装python MySQLdb

转自:https://my.oschina.net/jywm/blog/757973 安装步骤 在服务器安装了mysql 或者mysql-connect的前提下 1.安装setuptools 2.安装mysql-python 1.No module named setuptools *原因 没有安装setuptools工具 *解决方案 在python官网https://pypi.python.org搜 setuptools工具,复制工具连接,然后如下操作 #wget https://pypi.p

fedora安装mod_python

3.1 Installing mod_python To install mod_python, we simply run: yum install mod_python 3.2 Configuring Apache Now we must configure Apache so that it can handle Python files. There are two ways of doing so. The first (and default) one is to use the P

Mac OS X 下安装python的MySQLdb模块

参考资料: mac os x下python安装MySQLdb模块   http://www.codeif.com/post/1073/ MAC OSX使用Python安装模块有关问题  http://www.myexception.cn/operating-system/1616547.html 在Mac OS X 中安装好了MySQL和Django,在Django中访问MySQL数据库时,提示“ImportError: No module named MySQLdb”,是由于没有安装Pytho