我已經通過pip3安裝了MySQLdb,但是當我導入它時,它給了我錯誤。爲什麼?爲什麼pip3安裝軟件包雖然不能導入它?
pip3 install mysqlclient
Requirement already satisfied (use --upgrade to upgrade): mysqlclient in /usr/local/lib/python3.5/dist-packages
現在,當你看到它已經安裝了,但是當我將其導入它顯示了這一點:
Python 3.5.2 (default, Jun 30 2016, 12:36:02)
[GCC 5.3.1 20160413] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'MySQLdb'
>>>
跟它沒有模塊。我認爲我的Ubuntu筆記本電腦有兩個python3目錄,這是造成麻煩。一個是usr/local/bin,另一個是usr/bin。請幫忙。
'sudo pip3安裝MySQL-python' – frist