2015-10-25 77 views
0

得到錯誤在標題中導入錯誤:沒有模塊名爲連接器

OSX 10.10.5優勝美地(14F27) 蟒蛇2.7

路徑到MySQL /應用/ XAMPP/xamppfiles/bin中

echo $PATH 
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/XAMPP/xamppfiles/bin 

echo $PYTHONPATH 
:/Library/Python/2.7/site-packages/ 


pip list 
mysql-connector-python (2.0.4) 
mysql-connector-python-cext (2.1.3) 


import mysql.connector 
cnx = mysql.connector.connect(user='user', password='password', host='127.0.0.1', database='database') 
cnx.close() 

File "/Volumes/docs/python/TwtWth/mysql.py", line 7, in <module> 
    import mysql.connector 
ImportError: No module named connector 

import sys 
sys.path.insert(0, '/Library/Python/2.7/site-packages/mysql/connector') 
print "\n".join(sys.path) 
import mysql.connector 

ImportError: No module named connector 

有沒有人知道任何進一步的步驟挖?

回答

0

您是否正在檢查以確保您的pip軟件包包含在$PYTHONPATH

可能是一個在上面回聲$ PYTHONPATH後檢查

+0

:/Library/Python/2.7/site-packages/ – twtrbt

+0

會發生什麼事,當你''LS -lah /Library/Python/2.7/site -packages /''。 「pip」安裝在哪裏?你也可以嘗試''導入網站; site.getsitepackages()'' – StephenG

+0

@StephenG drwxr-xrwx 20 root wheel 680B Oct 24 23:48 .
drwxr-xr-x 3 root wheel 102B Sep 10 2014 ..
[email protected] 1 UserName wheel 18K Oct 25 18:59 .DS_Store
-rwxr-xr-x 1 7161 owner 52K Sep 10 13:32 _mysql_connector.so
drwxr-xrwx 6 root wheel 204B Oct 24 23:41 mysql
drwxr-xrwx 7 root wheel 238B Oct 24 19:04 mysql_connector_python-2.0.4-py2.7.egg-info
-rw-r--r-- 1 7161 owner 1.5K Sep 10 13:32 mysql_connector_python_cext-2.1.3-py2.7.egg-info
twtrbt

相關問題