国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Windows8下安裝Python的BeautifulSoup

2019-11-25 18:01:33
字體:
供稿:網(wǎng)友

運行環(huán)境:Windows 8.1
Python:2.7.6

在安裝的時候,我使用的pip來進(jìn)行安裝,命令如下:

復(fù)制代碼 代碼如下:

pip install beautifulsoup4

運行的時候,報錯如下:
復(fù)制代碼 代碼如下:

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行的

復(fù)制代碼 代碼如下:

default_encoding = sys.getdefaultencoding()

改成:
復(fù)制代碼 代碼如下:

if sys.getdefaultencoding() != 'gbk':
    reload(sys)
    sys.setdefaultencoding('gbk')
default_encoding = sys.getdefaultencoding()

安裝成功后,驗證是否安裝成功:

復(fù)制代碼 代碼如下:

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”沒有報錯的話,則說明安裝成功,否則,將報類似錯誤如下:
復(fù)制代碼 代碼如下:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named bs4

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 高邮市| 武穴市| 宜昌市| 三亚市| 会宁县| 长乐市| 曲靖市| 凌海市| 建瓯市| 呼玛县| 灌南县| 奉新县| 长春市| 正安县| 乌兰浩特市| 吴桥县| 崇仁县| 大方县| 延长县| 灯塔市| 无锡市| 贺州市| 外汇| 常山县| 宿迁市| 安龙县| 洪江市| 张家口市| 姜堰市| 景谷| 云林县| 娱乐| 泗水县| 绍兴县| 浦城县| 陆丰市| 东乌珠穆沁旗| 绥阳县| 兴义市| 临清市| 萨嘎县|