ubuntu下eclipse与python,mysql结合

以前在gentoo linux的eclipse安装过,想直接用以前的文件,结果不显示。

  • 环境

system:ubuntu12.04

eclipese:3.7.2

python:2.7.3

mysql:5.5

  • eclipe安装python插件
在eclipse菜单栏->eclipse maketplace->搜索pydev:

点击pydev for  eclipse  下的install就ok了,我这是因为已经安装了显示uninstall。

  • 安装mysql for python
到网站 http://pypi.python.org/simple/MySQL-python/ 下载 MySQL-python-1.2.3.tar.gz。

tar -zxvf MySQL-python-1.2.3.tar.gz

cd MySQL-python-1.2.3

python setup.py build

python setup.py install

error1:运行python setup.py build

sh: mysql_config: command not found
Traceback (most recent call last):
  File "setup.py", line 15, in ?
    metadata, options = get_config()
  File "/root/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "/root/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))

安装mysql-python时提示没有mysql_config文件。解决方法:安装mysql-client 和 libmysqlclient-dev包即解决。

error2:

If you get this error you need to install python-dev package:

 In file included from _mysql.c:29:
 pymemcompat.h:10:20: error: Python.h: No such file or directory
 _mysql.c:30:26: error: structmember.h: No such file or directory
 In file included from /usr/include/mysql/mysql.h:44,
                  from _mysql.c:40:
 .
 .
 .
 _mysql.c:2808: warning: return type defaults to 'int'
 _mysql.c: In function 'DL_EXPORT':
 _mysql.c:2808: error: expected declaration specifiers before 'init_mysql'
 _mysql.c:2886: error: expected '{' at end of input
 error: command 'gcc' failed with exit status 1

Installing the python-dev package on Debian is done with apt-get or synaptic:

 apt-get install python-dev

完成有,进入到python环境里。  

python

>>> import MySQLdb

>>>

如果没有错误,就正常了。

  • 配置pydev:安装完所有的东西后:

在eclipse菜单栏window下点击preferences->pydev->interpreter python:


点击右上方的aotuconfig,配置python的运行目录和各个lib位置。








  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值