Windows8下安裝Python的BeautifulSoup
運(yùn)行環(huán)境:Windows 8.1
Python:2.7.6
在安裝的時(shí)候,我使用的pip來(lái)進(jìn)行安裝,命令如下:
pip install beautifulsoup4
運(yùn)行的時(shí)候,報(bào)錯(cuò)如下:
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
解決方法:打開(kāi)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”沒(méi)有報(bào)錯(cuò)的話,則說(shuō)明安裝成功,否則,將報(bào)類似錯(cuò)誤如下:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named bs4
- python3第三方爬蟲庫(kù)BeautifulSoup4安裝教程
- Python爬蟲包BeautifulSoup簡(jiǎn)介與安裝(一)
- Python網(wǎng)頁(yè)解析利器BeautifulSoup安裝使用介紹
- python爬蟲開(kāi)發(fā)之Beautiful Soup模塊從安裝到詳細(xì)使用方法與實(shí)例
- python beautiful soup庫(kù)入門安裝教程
- python3解析庫(kù)BeautifulSoup4的安裝配置與基本用法
- python BeautifulSoup庫(kù)的安裝與使用
- python解析庫(kù)Beautiful?Soup安裝的詳細(xì)步驟
相關(guān)文章
Pandas實(shí)現(xiàn)數(shù)據(jù)拼接的操作方法詳解
Python處理大規(guī)模數(shù)據(jù)集的時(shí)候經(jīng)常需要使用到合并、鏈接的方式進(jìn)行數(shù)據(jù)集的整合,本文為大家主要介紹了.merge()、?.join()?和?.concat()?三種方法,感興趣的可以了解一下2022-04-04
如何利用python實(shí)現(xiàn)kmeans聚類
K-Means是聚類算法的一種,以距離來(lái)判斷數(shù)據(jù)點(diǎn)間的相似度并對(duì)數(shù)據(jù)進(jìn)行聚類,下面這篇文章主要給大家介紹了關(guān)于如何利用python實(shí)現(xiàn)kmeans聚類的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-05-05
如何解決Pycharm編輯內(nèi)容時(shí)有光標(biāo)的問(wèn)題
文章介紹了如何在PyCharm中配置VimEmulator插件,包括檢查插件是否已安裝、下載插件以及安裝IdeaVim插件的步驟2025-02-02
計(jì)算python腳本執(zhí)行時(shí)間的多種方法
在編寫Python腳本時(shí),了解腳本的執(zhí)行時(shí)間通常是很有用的,特別是在優(yōu)化代碼或評(píng)估性能時(shí),Python提供了多種方法來(lái)測(cè)量腳本的執(zhí)行時(shí)間,從內(nèi)置模塊到第三方庫(kù),可以選擇適合你需求的方式,本文將介紹計(jì)算 Python 腳本執(zhí)行時(shí)間的多種方法,需要的朋友可以參考下2023-11-11
跟老齊學(xué)Python之正規(guī)地說(shuō)一句話
雖然在第一部分中,已經(jīng)零星涉及到語(yǔ)句問(wèn)題,并且在不同場(chǎng)合也進(jìn)行了一些應(yīng)用。畢竟不那么系統(tǒng)。本部分,就比較系統(tǒng)地介紹python中的語(yǔ)句。2014-09-09
python GUI庫(kù)圖形界面開(kāi)發(fā)之PyQt5滾動(dòng)條控件QScrollBar詳細(xì)使用方法與實(shí)例
這篇文章主要介紹了python GUI庫(kù)圖形界面開(kāi)發(fā)之PyQt5滾動(dòng)條控件QScrollBar詳細(xì)使用方法與實(shí)例,需要的朋友可以參考下2020-03-03

