本教程操作环境:windows7系统、python3版、Dell G3电脑。
pip install 报错问题解决
相关免费学习推荐:python视频教程!
有时在用pip install命令安装python库时出现红字报错
1.报错:ReadTimeoutError: HTTPSConnectionPool(host=’pypi.python.org’, port=443): Read timed out.
Downloading xgboost-0.6a2.tar.gz (1.2MB) 48% |███████████████▋ | 583kB 47kB/s eta 0:00:13Exception:Traceback (most recent call last): File "c:\python27\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "c:\python27\lib\site-packages\pip\commands\install.py", line 335, in run wb.build(autobuilding=True) File "c:\python27\lib\site-packages\pip\wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "c:\python27\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "c:\python27\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "c:\python27\lib\site-packages\pip\download.py", line 821, in unpack_url hashes=hashes File "c:\python27\lib\site-packages\pip\download.py", line 659, in unpack_http_url hashes) File "c:\python27\lib\site-packages\pip\download.py", line 882, in _download_http_url _download_url(resp, link, content_file, hashes) File "c:\python27\lib\site-packages\pip\download.py", line 603, in _download_url hashes.check_against_chunks(downloaded_chunks) File "c:\python27\lib\site-packages\pip\utils\hashes.py", line 46, in check_against_chunks for chunk in chunks: File "c:\python27\lib\site-packages\pip\download.py", line 571, in written_chunks for chunk in chunks: File "c:\python27\lib\site-packages\pip\utils\ui.py", line 139, in iter for x in it: File "c:\python27\lib\site-packages\pip\download.py", line 560, in resp_read decode_content=False): File "c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\response.py", line 357, in stream data = self.read(amt=amt, decode_content=decode_content) File "c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\response.py", line 324, in read flush_decoder = True File "c:\python27\lib\contextlib.py", line 35, in __exit__ self.gen.throw(type, value, traceback) File "c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\response.py", line 246, in _error_catcher raise ReadTimeoutError(self._pool, None, 'Read timed out.') ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out.
错误原因:连不上pip的源,下载依赖包失败
解决(推荐):在pip安装所在文件夹路径下,创造python文件(.py)
import os ini="""[global] index-url = https://pypi.doubanio.com/simple/ [install] trusted-host=pypi.doubanio.com """ pippath=os.environ["USERPROFILE"]+"\\pip\\" if not os.path.exists(pippath): os.mkdir(pippath) with open(pippath+"pip.ini","w+") as f: f.write(ini)
在cmd上运行这个.py文件即可
之后再用pip install安装指令下载速度会非常快
2.报错:UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xd3 in position 7: ordinal not in range(128)
Exception: Traceback (most recent call last): File “c:\python27\lib\site-packages\pip\basecommand.py”, line 215, in main status = self.run(options, args) File “c:\python27\lib\site-packages\pip\commands\install.py”, line 324, in run requirement_set.prepare_files(finder) File “c:\python27\lib\site-packages\pip\req\req_set.py”, line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File “c:\python27\lib\site-packages\pip\req\req_set.py”, line 620, in _prepare_file session=self.session, hashes=hashes) File “c:\python27\lib\site-packages\pip\download.py”, line 821, in unpack_url hashes=hashes File “c:\python27\lib\site-packages\pip\download.py”, line 659, in unpack_http_url hashes) File “c:\python27\lib\site-packages\pip\download.py”, line 880, in _download_http_url file_path = os.path.join(temp_dir, filename) File “c:\python27\lib\ntpath.py”, line 85, in join result_path = result_path + p_path UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xd3 in position 7: ordinal not in range(128)
报错原因:pip安装Python包会加载目录包含中文字符,ascii不能编码
解决:python目录 Python27\Lib\site-packages 建一个文件sitecustomize.py
import sys sys.setdefaultencoding('gbk')
python会自动运行这个文件
以上就是pip install报错怎么办的详细内容,更多请关注亿码酷站其它相关文章!
pip install报错怎么办
—–文章转载自PHP中文网如有侵权请联系ymkuzhan@126.com删除
转载请注明来源:pip install报错怎么办
本文永久链接地址:https://www.ymkuzhan.com/30579.html
本文永久链接地址:https://www.ymkuzhan.com/30579.html
下载声明:
本站资源如无特殊说明默认解压密码为www.ymkuzhan.com建议使用WinRAR解压; 本站资源来源于用户分享、互换、购买以及网络收集等渠道,本站不提供任何技术服务及有偿服务,资源仅提供给大家学习研究请勿作它用。 赞助本站仅为维持服务器日常运行并非购买程序及源码费用因此不提供任何技术支持,如果你喜欢该程序,请购买正版! 版权声明:
下载本站资源学习研究的默认同意本站【版权声明】若本站提供的资源侵犯到你的权益,请提交版权证明文件至邮箱ymkuzhan#126.com(将#替换为@)站长将会在三个工作日内为您删除。 免责声明:
您好,本站所有资源(包括但不限于:源码、素材、工具、字体、图像、模板等)均为用户分享、互换、购买以及网络收集而来,并未取得原始权利人授权,因此禁止一切商用行为,仅可用于个人研究学习使用。请务必于下载后24小时内彻底删除,一切因下载人使用所引起的法律相关责任,包括但不限于:侵权,索赔,法律责任,刑事责任等相关责任,全部由下载人/使用人,全部承担。以上说明,一经发布视为您已全部阅读,理解、同意以上内容,如对以上内容持有异议,请勿下载,谢谢配合!支持正版,人人有责,如不慎对您的合法权益构成侵犯,请联系我们对相应内容进行删除,谢谢!