mac os 上安装mysqldb血泪史
昨天下午在mac上安装mysql-python一直未遂今天查了很多资料终于成功了 最后还是在stackoverflow点击打开链接(好网站啊,一般有什么技术问题在这都能找到)上找到了答案,废话少数:
首先,下载MySQLdb:http://sourceforge.net/projects/mysql-python/
下载MySQL-python-1.2.3.tar.gz
sh: mysql_config: command not found
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "/Users/***/Downloads/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/Users/***/Downloads/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
/Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg/_mysql.pyc, but /Users/***/Downloads/MySQL-python-1.2.3
is being added to sys.path
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MySQLdb/__init__.py", line 19, in <module>
import _mysql
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/***/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/***/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so
Reason: image not found
$ sudo python setup.py clean
$ sudo python setup.py build
$ sudo python setup.py install
$ export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
$python
>>> import MySQLdb
/Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg/_mysql.pyc, but /Users/***/Downloads/MySQL-python-1.2.3
is being added to sys.path
>>> conn=MySQLdb.connect(host="localhost",user="root",passwd="root",db="mysql")
>>> cursor =conn.cursor()
>>> sql ="select * from user"
>>> cursor.execute(sql)
7L
>>> row=cursor.fetchone()
>>> print row
('localhost', 'root', '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', '', '', '', '', 0L, 0L, 0L, 0L, '', '')
能够读取mysql.user表的信息了,说明已经mysqldb已经安装成功。
参考:http://stackoverflow.com/questions/1465846/install-mysqldb-on-snow-leopard/6537345#6537345
如果还是在eclipse中有问题,那就采用这里的办法 http://yanghao.org/blog/archives/76
解决办法: eclipse->偏好设置->Pydev->Interpreter-Python->Environment里面增加下面内容,看图:
Eclipse中配置MySQLdb模块
Window ——> Preferences ——> PyDev ——> Interpreter-Python ——> Forced Builtins ——> New... —— > 输入MySQLdb ——> OK
mac os 上安装mysqldb血泪史的更多相关文章
- 在Mac OS上安装Vagrant和Docker的教程
转载于:http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/128.html?1455808640 当听到很多人在说Docker是多么多 ...
- Mac OS 上安装 PostgreSQL
PostgreSQL Database Download https://www.enterprisedb.com/downloads/postgres-postgresql-downloads 下载 ...
- 在 Mac OS 上使用 TypeScript 编写 ASP.NET Core 1.0 应用
var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...
- 在 mac 系统上安装 python 的 MySQLdb 模块
在 mac 系统上安装 python 的 MySQLdb 模块 特别说明:本文主要参考了Mac系统怎么安装MySQLdb(MySQL-Python) 第 1 步:下载 MySQL-python-1.2 ...
- 转-在Mac OS上搭建Python的开发环境
在Mac OS上搭建Python的开发环境 本文转载自:http://www.jb51.net/article/76931.htm 一. 安装python mac系统其实自带了一个python的执 ...
- Xamarin+Prism开发详解四:简单Mac OS 虚拟机安装方法与Visual Studio for Mac 初体验
Mac OS 虚拟机安装方法 最近把自己的电脑升级了一下SSD固态硬盘,总算是有容量安装Mac 虚拟机了!经过心碎的安装探索,尝试了国内外的各种安装方法,最后在youtube上找到了一个好方法. 简单 ...
- 在 Mac OS 上创建并运行 ASP.NET Core 1.0 网站
var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...
- Mac OS 上设置 JAVA_HOME
Mac OS 上设置 JAVA_HOME 原文链接:http://han.guokai.blog.163.com/blog/static/136718271201301183938165/ 由于需要, ...
- 在 Mac OS 上编译 FFmpeg
本文转自:在 Mac OS 上编译 FFmpeg | www.samirchen.com 安装 Xcode 和 Command Line Tools 从 App Store 上安装 Xcode,并确保 ...
随机推荐
- View Component
View Component 在之前的MVC中,我们经常需要类似一种小部件的功能,通常我们都是使用Partial View来实现,因为MVC中没有类似Web Forms中的WebControl的功能. ...
- oracle_分区表的新增、修改、删除、合并。普通表转分区表方法
一. 分区表理论知识Oracle提供了分区技术以支持VLDB(Very Large DataBase).分区表通过对分区列的判断,把分区列不同的记录,放到不同的分区中.分区完全对应用透明. Oracl ...
- php_常用操作_读取文件_数据库操作
作为php新手 ,把经常用到的phpcode,做个备份 1: 文件处理 //读取配置 启动是指定文件 $filepath=$argv[1]; if(null==$filepath){ echo&quo ...
- projecteuler---->problem=19----Counting Sundays
You are given the following information, but you may prefer to do some research for yourself. 1 Jan ...
- hdu 5073 Galaxy(2014acm鞍山亚洲分部 D)
主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=5073 Galaxy Time Limit: 2000/1000 MS (Java/Others) ...
- 开发现代ASP.NET应用程序
新思想.新技术.新架构——更好更快的开发现代ASP.NET应用程序(续1) 今天在@张善友和@田园里的蟋蟀的博客看到微软“.Net社区虚拟大会”dotnetConf2015的信息,感谢他们的真诚付 ...
- The Swift Programming Language-官方教程精译Swift(3)基本运算符
运算符是检查, 改变, 合并值的特殊符号或短语. 例如, 加号 + 把计算两个数的和(如 let i = 1 + 2). 复杂些的运行算包括逻辑与&&(如 if enteredDoor ...
- 项目管理实践 -- 健身小管家(Fitness housekeeper)的管理
最近在网上看到一篇文章<王石:我每天都强迫自己做的一件事>,[http://blog.sina.com.cn/s/blog_4dfc1c330102v0d0.html] 原始链接不详. ...
- java设计模式之一工厂模式
简单工厂模式是java设计模式中最简单的设计模式之一: 工厂模式是最常用的设计模式之一. 工厂模式就相当于创建实例对象的new,我们经常要根据类Class生成实例对象,如A a=new A() 工厂模 ...
- 什么是EF, 和 Entity Framework Demo简单构建一个良好的发展环境
Entity Framwork(实体框架.缩写EF)这是ORM(Object Relational Mapping.对象映射关系)一个解决方案. EF的表映射为实体.并封装了操作方法.方便开发者 ...