Pip install bs4 gives _socketobject error

I am trying to install BeautifulSoup4 using the pip install BeautifulSoup4 command, according to 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 the terminal, I get an error message:

 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 the comments, I tried running sudo pip install pyopenssl , but I get the same "socketobject" error.

+7
python beautifulsoup
source share
5 answers

See fooobar.com/questions/416195 / ... :

Try:

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

Apparently, you cannot vote if there is an open reward.

Background:

This happened because Ubuntu 12.04 (this is my server OS) has an old pyOpenSSL that does not accept the attribute 'set_tlsext_host_name'. For correction, you need to add the dependency pyOpenSSL> = 0.13. On Ubuntu, use pip to upgrade pyOpenSSL, you also need to install libffi-dev and remove python-openssl with apt.

A source


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

0
source share

From what I understand, the version of the pyopenssl package installed in the system-wide is not updated. Update it:

 sudo pip install --upgrade pyopenssl 

Or remove it and install the latter in your virtual environment:

 $ sudo pip uninstall pyopenssl $ # activate virtual environment (myvirtualenv) $ pip install --upgrade pyopenssl 
+1
source share

β€œThis is because your OS has an old pyOpenSSL library that is not an accept attribute 'set_tlsext_host_name'. To fix this, you need to add the dependency pyOpenSSL> = 0.13.

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

Let me know if this is unclear or if it does not work for you.

+1
source share

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 that you will use. In addition, it simplifies the installation of the library.

0
source share

I am using OS X 10.12 and python 2.7.10

 sudo easy_install BeautifulSoup4 sudo easy_install pyopenssl 

They all worked great.

0
source share

All Articles