python - 运行 python 包失败
问题描述
编辑:我在评论部分尝试了该方法,现在问题变成了:
Traceback (most recent call last):
File "crawlertest.py", line 2, in <module>
from bs4 import BeautifulSoup
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/bs4/__init__.py", line 29, in <module>
from .builder import builder_registry
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/bs4/builder/__init__.py", line 7, in <module>
from bs4.element import (
ImportError: cannot import name 'Stylesheet'
我尝试安装 beautifulsoup4,
pip3 install beautifulsoup4
但它说
“无法获取 URL https://pypi.python.org/simple/beautifulsoup4/
确认 ssl 证书时出现问题:[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 警报协议版本 (_ssl.c :720)-跳过
找不到满足要求的版本beautifulsoup4(来自版本:)没有为beautifulsoup4找到匹配的发行版“
然后我尝试pip3 install --upgrade pip
然后再次安装并成功。我还安装了包“请求”。
但后来当我尝试在我的 Mac 上运行 requests 和 beautifulsoup4 时,它显示如下:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/connectionpool.py", line 706, in urlopen
chunked=chunked,
和类似的东西
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:720)
有什么办法可以解决吗?
解决方案
我认为您没有安装基本证书。
去:
Macintosh HD > Applications > Python3.x
并运行安装Certificates.command
另外,请参考以下链接:
推荐阅读
- javascript - 在日历中的特定日期显示背景颜色的问题,在除移动 Safari 之外的所有浏览器上都可以正常工作
- java - 在 teamcity 中覆盖或汇总测试结果
- flutter - Flutter没有导航到下一页上下文错误?
- python - sqlite - 迭代字典的问题
- java - 根据变量的值启用或禁用按钮
- angular - 将 ngIf 与子组件中的值一起使用
- c - 在多个 unsigned char 变量中输入十六进制值
- c - 我在指针数组和指向数组的指针之间与 openmp 的性能差异有什么问题?
- linux - 在使用 SQL Loader 加载的文件中使用时间戳
- c++ - 如何检查一个数字的不合理性