mac 下PyCharm執行報錯問題解決

wulantian發表於2015-04-09

今天在本機安裝配置python環境,本機執行沒問題,但是運用pycharm就報錯,明顯感覺是路徑環境問題。

做了修改vim /etc/profile 新增path, 以及vim /etc/bashrc 新增路徑,均不成功。後來做了2個軟連線問題解決:

 sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
 sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql


bogon:MySQL-python-1.2.5 coco$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

Password:

bogon:MySQL-python-1.2.5 coco$ sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql 





bogon:MySQL-python-1.2.5 coco$ export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

bogon:MySQL-python-1.2.5 coco$ python

Python 2.7.6 (default, Sep  9 2014, 15:04:36) 

[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin

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

>>> import MySQLdb

/Library/Python/2.7/site-packages/MySQL_python-1.2.5-py2.7-macosx-10.10-intel.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Python/2.7/site-packages/MySQL_python-1.2.5-py2.7-macosx-10.10-intel.egg/_mysql.pyc, but /Users/coco/Downloads/MySQL-python-1.2.5 is being added to sys.path

>>> import MySQLdb

>>> conn=MySQLdb.connect(host="192.168.8.96",user="muser",passwd="123456",db="mysql")

>>> cursor =conn.cursor()

>>> sql="select user,host from mysql.user"

>>> cursor.execute(sql)

8L

>>> row=cursor.fetchone()

>>> print row

('mha_user', '%')

>>> exit();



相關文章