gpt4 book ai didi

python - 尝试使用 pip3.4 在 CentOS 5.11 服务器中安装 python 模块 (beautifulsoup) 时出错

转载 作者:太空宇宙 更新时间:2023-11-04 10:39:01 25 4
gpt4 key购买 nike

我编写了一个 python3.4 脚本来从 RSS 提要中获取一些数据,它按预期工作。我想创建一个 cronjob 来使用我的 VPS (CentOS 5.11) 执行脚本。服务器安装了常规的 python 和 python3.4 没有问题(我可以毫无问题地运行 python3.4 脚本)。问题是我需要为 python3.4 安装 Beautiful Soup 才能让我的脚本工作,但是当我尝试安装它时,我从服务器收到错误消息:我用 pip3.4 install beautifulsoup安装模块。

Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/pip/basecommand.py", line 232, in main
status = self.run(options, args)
File "/usr/local/lib/python3.4/site-packages/pip/commands/install.py", line 339, in run
requirement_set.prepare_files(finder)
File "/usr/local/lib/python3.4/site-packages/pip/req/req_set.py", line 333, in prepare_files
upgrade=self.upgrade,
File "/usr/local/lib/python3.4/site-packages/pip/index.py", line 305, in find_requirement
page = self._get_page(main_index_url, req)
File "/usr/local/lib/python3.4/site-packages/pip/index.py", line 783, in _get_page
return HTMLPage.get_page(link, req, session=self.session)
File "/usr/local/lib/python3.4/site-packages/pip/index.py", line 872, in get_page
"Cache-Control": "max-age=600",
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/requests/sessions.py", line 473, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python3.4/site-packages/pip/download.py", line 365, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/requests/sessions.py", line 461, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/cachecontrol/adapter.py", line 43, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/requests/adapters.py", line 370, in send
timeout=timeout
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 518, in urlopen
body=body, headers=headers)
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 322, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 727, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/connection.py", line 238, in connect
ssl_version=resolved_ssl_version)
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py", line 254, in ssl_wrap_socket
return context.wrap_socket(sock)
File "/usr/local/lib/python3.4/ssl.py", line 365, in wrap_socket
_context=self)
File "/usr/local/lib/python3.4/ssl.py", line 542, in __init__
raise ValueError("check_hostname requires server_hostname")
ValueError: check_hostname requires server_hostname

我阅读了有关虚拟 python 环境的信息,但我不知道它是否会按照我想要的方式工作。我有服务器的根访问权限,我正在通过 SSH 执行此操作。

我们将不胜感激。


如果我使用 pip3.4 --trusted-host pypi.python.org install <package_name>我可以升级 pip3.4 并安装 urllib3,但是当我尝试安装 Beautiful Soup 时,我收到此错误:

Collecting beautifulsoup
/usr/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
Downloading BeautifulSoup-3.2.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-zgrqhr3v/beautifulsoup/setup.py", line 22
print "Unit tests have failed!"
^
SyntaxError: Missing parentheses in call to 'print'

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-zgrqhr3v/beautifulsoup/

最佳答案

您正在安装仅支持 python 2 的 beautifulsoup 版本 3。您需要安装支持 python 3 的 beautifulsoup 版本 4。

pip3.4 install beautifulsoup4

关于python - 尝试使用 pip3.4 在 CentOS 5.11 服务器中安装 python 模块 (beautifulsoup) 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36014916/

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