BeautifulSoup import error - Conflict with Python version

I installed BeautifulSoup with the command:

sudo easy_install BeautifulSoup4 

I got a message:

 Searching for BeautifulSoup4 Best match: beautifulsoup4 4.1.3 Processing beautifulsoup4-4.1.3-py2.6.egg beautifulsoup4 4.1.3 is already the active version in easy-install.pth Using /Library/Python/2.6/site-packages/beautifulsoup4-4.1.3-py2.6.egg Processing dependencies for BeautifulSoup4 Finished processing dependencies for BeautifulSoup4 

I am trying to import the BeautifulSoup library.

 >>> from BeautifulSoup import BeautifulSoup Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named BeautifulSoup 

or

 >>> from bs4 import BeautifulSoup Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named bs4 

My Python version:

 python --version Python 2.7.3 

EDIT

I understand that:

 Using /Library/Python/2.6/site-packages/beautifulsoup4-4.1.3-py2.6.egg 

May indicate a conflict between versions of Python

How can I register this module? Thanks

0
source share
3 answers

After some research, I found that this solves the problem:

 pip uninstall BeautifulSoup4 

will remove the package located in:

 /Library/Python/2.6/site-packages/ 

and

 easy_install-2.7 BeautifulSoup4 

successfully install the package in:

 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ 

I checked the process also with some other packages having the same problems and it works.

0
source

Must be

 from bs4 import BeautifulSoup 
+3
source

Do it:

  • easy_install pip
  • When this is done, restart and type pip install beautifulsoup4 . That should work.

Make sure you have a module with pip list , if you see Beautiful Soup as the output, then yes, you are working.

0
source

Source: https://habr.com/ru/post/986090/


All Articles