Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] beginner help
#1
I am completely new about Python and on this forum. I installed Python 3.8.0 (64-bit), and learned that I need BeautifulSoup for webscraping. So I tried to install this tool several times with the help of YouTube instructions, but never got conformation that the installation was OK. Due to these attempts, maybe the directory structure inside my Python became a little mess. Indeed, I see that I have two library-maps: "Libs" and "lib", both containing a map "BeautifulSoup4-4.8.0".
I suppose I have to suppress one of them ?
When I try with Python "from bs4 import beautifulsoup" I get the message:
"You are trying to run the Python2-version of Beautiful Soup under Python3 - this will not work - You need to convert the code either by installing it (python setup.py install) or by running 2to3 (2to3 -w bs4)".
I tried both: when I enter in Python "python setup.py install" I get: "invalid syntax", and also after entering "2to3 -w bs4" I get same message.
What am I doing wrong ??

Many thanks
Reply
#2
(Nov-20-2019, 09:31 AM)AMT59 Wrote: I am completely new about Python and on this forum. I installed Python 3.8.0 (64-bit), and learned that I need BeautifulSoup for webscraping.

Hi!

I would uninstall everything and start again, but instead of Python 3.8.0, I would install Python 3.7.4. For the installation of BeautifulSoup, you can follow instructions in my post (#4) on this thread:

https://python-forum.io/Thread-Windows-c...d-packages

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#3
You install with pip install beautifulsoup4
Test with 3.8.
C:\Python38\Scripts
λ pip install beautifulsoup4
Collecting beautifulsoup4
  Downloading ....
Installing collected packages: soupsieve, beautifulsoup4
Successfully installed beautifulsoup4-4.8.1 soupsieve-1.9.5
# Test
C:\Python38\Scripts
λ cd ..

C:\Python38
λ python
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import bs4
>>> bs4.__version__
'4.8.1'

>>> # The normal import you use
>>> from bs4 import BeautifulSoup
>>>
Here i just do it folder of 3.8 as i still have 3.7 set as main version in Windows Path.
Python 3.6/3.7 and pip installation under Windows

As you see it work as it should,there has been some problem with some libraries on 3.8 Windows
eg matplotlib,Scipy,NumPy.
This has been is reported and will be fixed,or can also use wheel from gohlke.
Reply
#4
(Nov-20-2019, 12:01 PM)newbieAuggie2019 Wrote:
(Nov-20-2019, 09:31 AM)AMT59 Wrote: I am completely new about Python and on this forum. I installed Python 3.8.0 (64-bit), and learned that I need BeautifulSoup for webscraping.

Hi!

I would uninstall everything and start again, but instead of Python 3.8.0, I would install Python 3.7.4. For the installation of BeautifulSoup, you can follow instructions in my post (#4) on this thread:

https://python-forum.io/Thread-Windows-c...d-packages

All the best,

I believe this would work for me too, thanks!
Reply
#5
Hello newbieAuggie2019. Thx for your instructions. I followed them and installed Python 3.7.4.
However after "pip install beautifulsoup4" I get message:
requirement already satisfied: beautifulsoup4 in c:>\program files\python37\lib\site packages (4.8.1)
requirement already satisfied: soupsieve>=1.2 in c:>\program files\python37\lib\site packages (from beautifulsoup4) (1.5)
When I ask in Python import for bs4 and soupsieve, this is OK, but import beautifulsoup4 gives "ModuleNotFoundError: no module named 'beautifulsoup4'.
When I look in lib I see maps bs4 and soupsieve, but no map beautifulsoup4 (only beautifulsoup4-4.8.1.dist.info)

best regards
Reply
#6
beautifulsoup4 is imported with "import bs4" that´s it!

This is the way to import it, why do you insist on importing a false name?
Reply
#7
(Nov-21-2019, 12:01 PM)AMT59 Wrote: When I ask in Python import for bs4 and soupsieve, this is OK, but import beautifulsoup4 gives "ModuleNotFoundError: no module named 'beautifulsoup4'.
It's not called beautifulsoup4 when you import it,only when install it.
As i have in my post.
>>> # The normal import you use
>>> from bs4 import BeautifulSoup
>>>
Web-Scraping part-1.
Reply
#8
(Nov-21-2019, 12:01 PM)AMT59 Wrote: import beautifulsoup4 gives "ModuleNotFoundError: no module named 'beautifulsoup4'.
Hi!

It gives you a 'ModuleNotFoundError' because you are not following the instructions ...
In my post (#4), point 3):

https://python-forum.io/Thread-Windows-c...d-packages

I included a test program to check beautifulSoup, where you can clearly see that the correct way to import beautifulSoup is:
from bs4 import BeautifulSoup
All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#9
OK guys, I should look more in detail. sorry …. It is working now. Great thanks to help me out !!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Python beginner: Weird Syntax Error mnsaathvika 1 2,096 Jul-22-2019, 06:14 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020