7

I am trying to install BeautifulSoup4 using the command pip install BeautifulSoup4, as per the bs documentation here:

https://www.crummy.com/software/BeautifulSoup/#Download

I am using Mac OS X 10.7.5, and python 2.7.12

When I run the command in Terminal I get the error:

AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'

Can anyone suggest what I'm doing wrong? Thanks in advance.

EDIT: In light of comments I have tried to run sudo pip install pyopenssl however I get the same 'socketobject' error.

Preston
  • 7,399
  • 8
  • 54
  • 84

5 Answers5

1

From what I understand, the pyopenssl package version installed system-wide is not up-to-date. Upgrade it:

sudo pip install --upgrade pyopenssl

Or, remove it and install the latest in your virtual environment:

$ sudo pip uninstall pyopenssl
$ # activate virtual environment
(myvirtualenv) $ pip install --upgrade pyopenssl
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
1

"That happend because your OS has old pyOpenSSL library which is does not an accept attribute 'set_tlsext_host_name'. To fix this, you need to add dependence pyOpenSSL >= 0.13.

$ brew purge python-openssl
$ brew install libffi-dev
$ brew install pyOpenSSL

Let me know if this is unclear or if it doesn't work for you.

Prakhar Agarwal
  • 2,724
  • 28
  • 31
0

Alternatively, you can install Anaconda Python from: https://www.continuum.io/downloads

This installation includes BS out of the box as most of the common libraries you will use. Plus it makes library installation quite easy.

dgg32
  • 1,409
  • 1
  • 13
  • 33
0

I'm using OS X 10.12 and python 2.7.10

sudo easy_install BeautifulSoup4
sudo easy_install pyopenssl

They all worked fine.

Jared Chu
  • 2,757
  • 4
  • 27
  • 38
0

See https://stackoverflow.com/a/31576259/3579910:

Try:

sudo apt-get purge python-openssl
sudo apt-get install libffi-dev
sudo pip install pyopenssl

Apparently you can't vote duplicate if there is an open bounty.

Background:

That happend because Ubuntu 12.04 (that is my server's OS) has old pyOpenSSL library which not accept attribute 'set_tlsext_host_name'. For fix that, you need to add dependence pyOpenSSL >= 0.13. On Ubuntu for update pyOpenSSL use pip, you also need to install libffi-dev and remove python-openssl by apt.

Source


On Mac, you can get homebrew to replace the apt-get calls: follow the instructions for installing homebrew.

Community
  • 1
  • 1
TemporalWolf
  • 7,727
  • 1
  • 30
  • 50