gpt4 book ai didi

python-2.7 - 如何使用python2.7在64位Windows 10机器上安装lxml

转载 作者:太空宇宙 更新时间:2023-11-03 13:31:03 24 4
gpt4 key购买 nike

我正在尝试运行一个 python 文件,要求 lxml 出现以下错误。我的是公司笔记本电脑,win 10 64bitpython 2.7 已经安装。

C:\Users\dgutti\Desktop\Updates>python semp_main.py Traceback (most recent call last): File "semp_main.py", line 5, in import readBuildFile as read_build File "C:\Users\dgutti\Desktop\Updates\readBuildFile.py", line 1, in from lxml import etree ImportError: No module named lxml

我尝试使用 pip 安装 lxml,但出现 SSL 错误,所以我尝试信任主机。但没有任何作用。任何人都可以帮助如何执行 使用 lxml 的 python 文件?

C:\Program Files\Python27\Scripts>pip install lxml Collecting lxml
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/lxml/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:726)'),)': /simple/lxml/ Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/lxml/ Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/lxml/ Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:726)'),)': /simple/lxml/ Could not fetch URL https://pypi.python.org/simple/lxml/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/lxml/ (Caused by SSLError(SSLError(1, u'[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:726)'),)) - skipping Could not find a version that satisfies the requirement lxml (from versions: ) No matching distribution found for lxml

C:\Program Files\Python27\Scripts>pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org lxml Collecting lxml Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/lxml/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/lxml/ Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/lxml/ Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:726)'),)': /simple/lxml/ Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/lxml/ Could not find a version that satisfies the requirement lxml (from versions: ) No matching distribution found for lxml

C:\Program Files\Python27>python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/pip/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/pip/ Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/pip/ Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/pip/ Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/pip/ Requirement already up-to-date: pip in c:\program files\python27\lib\site-packages

最佳答案

如果您的 PC 在公司防火墙后面,您可能需要为 pip 指定代理。您可以通过在启动 pip 之前在 CMD 窗口中设置 http_proxyhttps_proxy 变量来实现:

set http_proxy=http://<<Proxy IP address>>:<<Proxy IP port>>
set https_proxy=http://<<Proxy IP address>>:<<Proxy IP port>>

还可以考虑设置 no_proxy 变量来指定应该绕过代理访问哪些网络:

set no_proxy=127.0.0.1,<<Other local networks>>

关于python-2.7 - 如何使用python2.7在64位Windows 10机器上安装lxml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54805460/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com