【已解決】windows下,安裝python的chardet

最簡單方便快捷的方法就是: 下載.egg 的安裝包。。。改後綴爲zip 直接解壓放進去就好了。。。    第一次的時候下的就是.egg 的,但是不知道怎麼打開,就去官網下.zip  安裝的時候提示錯誤。。。 找啊找   終於找到了這篇教程。。。

文章轉載於: http://download.csdn.net/download/aqwd2008/4256178

另可參考: http://blog.csdn.net/xufei96/article/details/6904132



【已解決】windows下,安裝python的chardet

【背景】

想要安裝python下面的chardet庫。

【解決過程】

1.從官網

http://pypi.python.org/pypi/chardet#downloads

中下載了chardet-1.0.1.tar.gz

解壓後,進去目錄去運行setup.py,結果出錯:

D:tmpWordPressOtherspythonchardetchardet-1.0.1.tarchardet-1.0.1>python setup.py
Traceback (most recent call last):
File “setup.py”, line 1, in <module>
from setuptools import setup
ImportError: No module named setuptools

D:tmpWordPressOtherspythonchardetchardet-1.0.1.tarchardet-1.0.1> setup.py install
Traceback (most recent call last):
File “D:tmpWordPressOtherspythonchardetchardet-1.0.1.tarchardet-1.0.1setup.py”, line 1, in <module>
from setuptools import setup
ImportError: No module named setuptools

D:tmpWordPressOtherspythonchardetchardet-1.0.1.tarchardet-1.0.1>setup.py install
Traceback (most recent call last):
File “D:tmpWordPressOtherspythonchardetchardet-1.0.1.tarchardet-1.0.1setup.py”, line 1, in <module>
from setuptools import setup
ImportError: No module named setuptools

D:tmpWordPressOtherspythonchardetchardet-1.0.1.tarchardet-1.0.1>python setup.py
Traceback (most recent call last):
File “setup.py”, line 1, in <module>
from setuptools import setup
ImportError: No module named setuptools

D:tmpWordPressOtherspythonchardetchardet-1.0.1.tarchardet-1.0.1>setup.py build
Traceback (most recent call last):
File “D:tmpWordPressOtherspythonchardetchardet-1.0.1.tarchardet-1.0.1setup.py”, line 1, in <module>
from setuptools import setup
ImportError: No module named setuptools

網上找了一堆解釋,也都沒用。

後來才知道,需要安裝對應的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安裝目錄Libsite-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,然後解壓,即可

發佈了30 篇原創文章 · 獲贊 9 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章