windows環境安裝MySQLdb

來源:互聯網
上載者:User

標籤:imp   mysqldb   代碼   網盤下載   dash   red   matching   下載   window   

一、環境

系統:win7,64位

python版本:2.7.15

pip版本:10.0.1

 

二、安裝1. 用pip安裝
pip install MySQLdb

報錯:

Could not find a version that satisfies the requirement MySQLdb (from versions: )No matching distribution found for MySQLdb

這個問題在網上搜了很久,其中有一篇文章[1]給出了兩個原因:

  • PyPI 伺服器將你的ip加入黑名單了
  • 你的pip版本過低

不過我是能開啟https://pypi.python.org的,所以排除第一點。

然後升級pip:

python -m pip install --upgrade pip

提示已經是最高版本了,所以這點也排除。當時沒想到別的可能,所以在這裡卡了很久。

還有什麼可能呢——伺服器裡找不到這個庫。

直接開啟詳細模式來安裝:

pip install MySQLdb -v

觀察安裝過程,可以看到一些有價值的資訊:

Analyzing links from page 
https://pypi.org/simple/mysqldb/
  Could not find a version that satisfies the requirement MySQLdb (from versions: )

表明無法在伺服器裡找到相應的資訊。

實際上,在windows系統中,還是只能通過exe進行安裝。

 

2. 安裝驅動mysql-python

一般有兩種方式,一種是安裝編譯好的版本,一種是從官網下代碼自己編,據說第二種非常慢而且依賴平台,所以一般還是建議選擇第二種。

我的情況需要安裝MySQL-python-1.2.3.win-amd64-py2.7_2,下載並安裝。

:https://sourceforge.net/projects/mysqlpythonwinx64py272/?source=typ_redirect

也可以直接從我的網盤下載:https://pan.baidu.com/s/1Hi_7Z-lLSLVa2Zo900tJnQ,密碼:dair

其他的版本在 http://www.codegood.com/downloads 可以找到,根據自己情況去選擇。

 

安裝完之後,驗證一下:

>>> import MySQLdb>>>

成功!

 

三、參考

1. Fix the pip error: Couldn‘t find a version that satisfies the requirement

2. python MySQLdb在windows環境下的快速安裝、問題解決方式

windows環境安裝MySQLdb

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.