【解決過程】
1.從官網
http://pypi.python.org/pypi/chardet#downloads
中下載了chardet-1.0.1.tar.gz
解壓後,進去目錄去運行setup.py,結果出錯:
D:\tmp\WordPress\Others\python\chardet\chardet-1.0.1.tar\chardet-1.0.1>python setup.py
D:\tmp\WordPress\Others\python\chardet\chardet-1.0.1.tar\chardet-1.0.1> setup.py install
D:\tmp\WordPress\Others\python\chardet\chardet-1.0.1.tar\chardet-1.0.1>setup.py install
D:\tmp\WordPress\Others\python\chardet\chardet-1.0.1.tar\chardet-1.0.1>python setup.py
D:\tmp\WordPress\Others\python\chardet\chardet-1.0.1.tar\chardet-1.0.1>setup.py build |
網上找了一堆解釋,也都沒用。
後來才知道,需要安裝對應的setuptools的。
覺得還是挺麻煩的。懶得去裝了。
2.後來參考了這裏:
http://apps.hi.baidu.com/share/detail/17694911
其解釋的算是很清楚,不過後面的回覆,更有用:
“呵呵,其實很簡單,直接把.egg解壓放在lib/site-packages中即可。”
所以,去把剛纔已經解壓chardet-1.0.1-py2.5.zip而得到的文件夾chardet-1.0.1-py2.5下面的chardet目錄及其下面所有文件,一起都拷貝粘貼到
python安裝目錄\Lib\site-packages
下面,即可。其他啥都不需要再折騰了。
【總結】
普通的下載的庫:chardet-1.0.1.tar.gz中包括setup.py,由於需要setuptools,而我當前沒有,所以沒法繼續安裝。
而另外去下載egg版本的:chardet-1.0.1-py2.5.zip,解壓後,直接把chardet拷貝到lib/site-packages,就可以了,也就不需要額外去折騰其他的了。
所以,以後安裝python中的庫的話,最簡單的方法就是:
1.下載egg版本的
2.解壓
3.拷貝到lib/site-packages
【後記】
後來去下載egg版本的,結果後綴就是.egg,不知道如何打開。
後來才搞懂,自己直接把後綴.egg改爲.zip,然後解壓,即可。