Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip install bs4 giving _socketobject error

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.

like image 875
Preston Avatar asked Oct 08 '16 17:10

Preston


2 Answers

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
like image 83
alecxe Avatar answered Sep 20 '22 03:09

alecxe


"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.

like image 45
Prakhar Agarwal Avatar answered Sep 23 '22 03:09

Prakhar Agarwal