C:\Users\Administrator>pip install beautifulsoup4 Collecting beautifulsoup4 Exception: Traceback (most recent call last): File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\basecommand.py", line 215, in main status = self.run(options, args) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\commands\install.py", line 299, in run requirement_set.prepare_files(finder) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\req\req_set.py", line 370, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\req\req_set.py", line 522, in _prepare_file finder, self.upgrade, require_hashes) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\req\req_install.py", line 268, in populate_link self.link = finder.find_requirement(self, upgrade) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\index.py", line 442, in find_requirement all_candidates = self.find_all_candidates(req.name) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\index.py", line 400, in find_all_candidates for page in self._get_pages(url_locations, project_name): File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\index.py", line 545, in _get_pages page = self._get_page(location) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\index.py", line 648, in _get_page return HTMLPage.get_page(link, session=self.session) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\index.py", line 757, in get_page "Cache-Control": "max-age=600", File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\requests\sessions.py", line 487, in get return self.request('GET', url, **kwargs) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\download.py", line 378, in request return super(PipSession, self).request(method, url, *args, **kwargs) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\requests\sessions.py", line 475, in request resp = self.send(prep, **send_kwargs) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\requests\sessions.py", line 617, in send r.content File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\requests\models.py", line 741, in content self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes() File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\requests\models.py", line 664, in generate for chunk in self.raw.stream(chunk_size, decode_content=True): File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\requests\packages\urllib3\response.py", line 353, in stream data = self.read(amt=amt, decode_content=decode_content) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\requests\packages\urllib3\response.py", line 310, in read data = self._fp.read(amt) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\cachecontrol\filewrapper.py", line 54, in read self.__callback(self.__buf.getvalue()) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\cachecontrol\controller.py", line 297, in cache_response self.serializer.dumps(request, response, body=body), File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\download.py", line 281, in set return super(SafeFileCache, self).set(*args, **kwargs) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\cachecontrol\caches\file_cache.py", line 99, in set with self.lock_class(name) as lock: File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\lockfile\mkdirlockfile.py", line 19, in __init__ LockBase.__init__(self, path, threaded, timeout) File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\lockfile\__init__.py", line 242, in __init__ hash(self.path))) File "C:\Python27\lib\ntpath.py", line 85, in join result_path = result_path + p_path UnicodeDecodeError: 'ascii' codec can't decode byte 0xc0 in position 0: ordinal not in range(128)
pip list这些语句能用,就是在安装包的时候一直报错,网上没有相关的信息。
麻烦大家看一下,谢谢。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
1、在Python的安装目录C:/Python27/Lib/里找到mimetypes.py文件;2、打开mimetypes.py文件,在import结束后添加以下代码:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
保存文件 重新执行pip即可