Windows8下安裝Python的BeautifulSoup
運(yùn)行環(huán)境:Windows 8.1
Python:2.7.6
在安裝的時候,我使用的pip來進(jìn)行安裝,命令如下:
pip install beautifulsoup4
運(yùn)行的時候,報(bào)錯如下:
Exception:
Traceback (most recent call last):
File "J:\Program Files (x86)\Python\Python27\lib\site-packages\pip\basecomm
.py", line 122, in main
status = self.run(options, args)
File "J:\Program Files (x86)\Python\Python27\lib\site-packages\pip\commands
stall.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bu
e=self.bundle)
File "J:\Program Files (x86)\Python\Python27\lib\site-packages\pip\req.py",
ne 1229, in prepare_files
req_to_install.run_egg_info()
File "J:\Program Files (x86)\Python\Python27\lib\site-packages\pip\req.py",
ne 292, in run_egg_info
logger.notify('Running setup.py (path:%s) egg_info for package %s' % (sel
etup_py, self.name))
File "J:\Program Files (x86)\Python\Python27\lib\site-packages\pip\req.py",
ne 265, in setup_py
import setuptools
File "build\bdist.win-amd64\egg\setuptools\__init__.py", line 11, in <modul
from setuptools.extension import Extension
File "build\bdist.win-amd64\egg\setuptools\extension.py", line 5, in <modul
File "build\bdist.win-amd64\egg\setuptools\dist.py", line 15, in <module>
File "build\bdist.win-amd64\egg\setuptools\compat.py", line 19, in <module>
File "J:\Program Files (x86)\Python\Python27\lib\SimpleHTTPServer.py", line
, in <module>
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
File "J:\Program Files (x86)\Python\Python27\lib\SimpleHTTPServer.py", line
8, in SimpleHTTPRequestHandler
mimetypes.init() # try to read system mime.types
File "J:\Program Files (x86)\Python\Python27\lib\mimetypes.py", line 358, i
nit
db.read_windows_registry()
File "J:\Program Files (x86)\Python\Python27\lib\mimetypes.py", line 258, i
ead_windows_registry
for subkeyname in enum_types(hkcr):
File "J:\Program Files (x86)\Python\Python27\lib\mimetypes.py", line 249, i
num_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordin
not in range(128)
Storing debug log for failure in C:\Users\Administrator\pip\pip.log
解決方法:打開C:\Python27\Lib下的 mimetypes.py 文件,找到大概256行的
default_encoding = sys.getdefaultencoding()
改成:
if sys.getdefaultencoding() != 'gbk':
reload(sys)
sys.setdefaultencoding('gbk')
default_encoding = sys.getdefaultencoding()
安裝成功后,驗(yàn)證是否安裝成功:
C:\Users\Administrator>python
Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on 32
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import BeautifulSoup
>>> exit()
如果“from bs4 import BeautifulSoup”沒有報(bào)錯的話,則說明安裝成功,否則,將報(bào)類似錯誤如下:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named bs4
相關(guān)文章
python opencv 檢測移動物體并截圖保存實(shí)例
這篇文章主要介紹了python opencv 檢測移動物體并截圖保存實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-03-03Python matplotlib實(shí)現(xiàn)散點(diǎn)圖的繪制
Matplotlib作為Python的2D繪圖庫,它以各種硬拷貝格式和跨平臺的交互式環(huán)境生成出版質(zhì)量級別的圖形。本文將利用Matplotlib庫繪制散點(diǎn)圖,感興趣的可以了解一下2022-03-03詳解python 3.6 安裝json 模塊(simplejson)
這篇文章主要介紹了python 3.6 安裝json 模塊(simplejson),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04python代碼如何調(diào)出cmd命令行窗口并在cmd窗口中執(zhí)行指定的命令
這篇文章主要介紹了python代碼如何調(diào)出cmd命令行窗口并在cmd窗口中執(zhí)行指定的命令問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-02-02Python sqlparse解析SQL表血緣追蹤實(shí)現(xiàn)
這篇文章主要為大家介紹了Python sqlparse解析SQL表血緣追蹤實(shí)現(xiàn),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-10-10Python字符串和字典相關(guān)操作的實(shí)例詳解
這篇文章主要介紹了Python字符串和字典相關(guān)操作的實(shí)例詳解的相關(guān)資料,這里提供實(shí)例幫助大家學(xué)習(xí)理解這部分內(nèi)容,需要的朋友可以參考下2017-09-09Python抖音快手代碼舞(字符舞)的實(shí)現(xiàn)方法
這篇文章主要給大家介紹了關(guān)于Python抖音快手代碼舞的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-02-02django創(chuàng)建超級用戶時指定添加其它字段方式
這篇文章主要介紹了django創(chuàng)建超級用戶時指定添加其它字段方式,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-05-05