Install Python BeautifulSoup in Windows 8

Source: Internet
Author: User
This article describes how to install Python BeautifulSoup in Windows 8. This article focuses on the installation errors and solutions. if you need a friend, refer to the running environment: Windows 8.1
Python: 2.7.6

During installation, I use pip for installation. the command is as follows:

The code is as follows:


Pip install beautifulsoup4


When running, the following error is reported:

The code is as follows:


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. runner Y ('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 From setuptools. extension import Extension
File "build \ bdist. win-amd64 \ egg \ setuptools \ extension. py", line 5, in File "build \ bdist. win-amd64 \ egg \ setuptools \ dist. py", line 15, in
File "build \ bdist. win-amd64 \ egg \ setuptools \ compat. py", line 19, in
File "J: \ Program Files (x86) \ Python \ Python27 \ lib \ SimpleHTTPServer. py", line
, In
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. log

Solution: Open the mimetypes. py file under C: \ Python27 \ Lib and find

The code is as follows:


Default_encoding = sys. getdefaultencoding ()


Changed:

The code is as follows:


If sys. getdefaultencoding ()! = 'Gbk ':
Reload (sys)
Sys. setdefaultencoding ('gbk ')
Default_encoding = sys. getdefaultencoding ()

After the installation is successful, verify whether the installation is successful:

The code is as follows:


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 ()


If no error is reported for "from bs4 import BeautifulSoup", the installation is successful. Otherwise, a similar error is reported as follows:

The code is as follows:


Traceback (most recent call last ):
File" ", Line 1, in
ImportError: No module named bs4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.