安装前先检查电脑是否完成对pip的环境变量的配置
1.Win + R :进入命令行
2.直接输入:pip --version 如果不行试试 python -m pip --version
3.开始安装lxml : pip install lxml
你以为不会出意外,但是因为就是发生了。
这时候我预测到你应该是报错成这样了
ERROR: Exception: Traceback (most recent call last): File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcher yield File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\urllib3\response.py", line 561, in read data = self._fp_read(amt) if not fp_closed else b"" File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\urllib3\response.py", line 527, in _fp_read return self._fp.read(amt) if amt is not None else self._fp.read() File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 98, in read data: bytes = self.__fp.read(amt) File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 464, in read s = self.fp.read(amt) File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\socket.py", line 705, in readinto return self._sock.recv_into(b) File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1273, in recv_into return self.read(nbytes, buffer) File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1129, in read return self._sslobj.read(len, buffer) TimeoutError: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\base_command.py", line 105, in _run_wrapper status = _inner_run() File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\base_command.py", line 96, in _inner_run return self.run(options, args) File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\req_command.py", line 67, in wrapper return func(self, options, args) File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\commands\install.py", line 379, in run requirement_set = resolver.resolve( File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 179, in resolve self.factory.preparer.prepare_linked_requirements_more(reqs) File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\operations\prepare.py", line 554, in prepare_linked_requirements_more self._complete_partial_requirements( File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\operations\prepare.py", line 469, in _complete_partial_requirements for link, (filepath, _) in batch_download: File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\network\download.py", line 184, in __call__ for chunk in chunks: File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\progress_bars.py", line 55, in _rich_progress_bar for chunk in iterable: File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\network\utils.py", line 65, in response_chunks for chunk in response.raw.stream( File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\urllib3\response.py", line 622, in stream data = self.read(amt=amt, decode_content=decode_content) File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\urllib3\response.py", line 560, in read with self._error_catcher(): File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 153, in __exit__ self.gen.throw(typ, value, traceback) File "C:\Users\32595\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\urllib3\response.py", line 443, in _error_catcher raise ReadTimeoutError(self._pool, None, "Read timed out.") pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
网上我看见了很多很多人都是给了你很多条建议,很多家镜像,但是我这几天去弄的时候发现好多都不能用,所以我给大家多总结一些,大家按照先后顺序去用,一个不行换下一个,肯定有那么一个是可以的。
#阿里云镜像下下载
pip install lxml -i https://mirrors.aliyun.com/pypi/simple
#清华大学镜像下下载
pip install lxml -i https://pypi.tuna.tsinghua.edu.cn/simple
#豆瓣镜像下下载
pip install lxml -i https://pypi.douban.com/simple
#中国科技大学镜像下下载
pip install lxml -i https://pypi.mirrors.ustc.edu.cn/simple