Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #71256 > unrolled thread

How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

Started bySimon Evans <musicalhacksaw@yahoo.co.uk>
First post2014-05-10 09:58 -0700
Last post2014-05-12 09:23 -0700
Articles 20 on this page of 42 — 9 participants

Back to article view | Back to comp.lang.python


Contents

  How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-10 09:58 -0700
    Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Chris Angelico <rosuav@gmail.com> - 2014-05-11 03:03 +1000
    Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Terry Reedy <tjreedy@udel.edu> - 2014-05-10 14:39 -0400
    Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Chris Angelico <rosuav@gmail.com> - 2014-05-11 09:23 +1000
    Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Dave Angel <d@davea.name> - 2014-05-10 22:16 -0400
    Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-11 12:05 -0700
      Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Chris Angelico <rosuav@gmail.com> - 2014-05-12 05:17 +1000
        Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-11 13:03 -0700
          Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. MRAB <python@mrabarnett.plus.com> - 2014-05-11 21:19 +0100
      Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Terry Reedy <tjreedy@udel.edu> - 2014-05-11 16:31 -0400
        Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-11 15:03 -0700
          Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. MRAB <python@mrabarnett.plus.com> - 2014-05-11 23:10 +0100
            Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-11 16:19 -0700
              Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-11 16:22 -0700
                Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-11 16:37 -0700
              Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Ian Kelly <ian.g.kelly@gmail.com> - 2014-05-11 17:47 -0600
                Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-12 09:35 -0700
                  Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-12 12:17 -0700
                  Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Ian Kelly <ian.g.kelly@gmail.com> - 2014-05-12 16:54 -0600
                    Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-13 04:52 -0700
                    Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-13 04:59 -0700
                      Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-13 14:23 +0100
                      Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. MRAB <python@mrabarnett.plus.com> - 2014-05-13 15:48 +0100
                        Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-14 12:28 -0700
                          Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Ian Kelly <ian.g.kelly@gmail.com> - 2014-05-14 13:33 -0600
                          Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Chris Angelico <rosuav@gmail.com> - 2014-05-15 05:36 +1000
                            Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-15 02:22 -0700
                              Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-15 04:25 -0700
                                Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-15 04:30 -0700
                                  Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Dave Angel <davea@davea.name> - 2014-05-15 08:12 -0400
                                Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Rustom Mody <rustompmody@gmail.com> - 2014-05-15 05:17 -0700
                      Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Ian Kelly <ian.g.kelly@gmail.com> - 2014-05-13 10:33 -0600
                        Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-14 11:58 -0700
                          Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Ian Kelly <ian.g.kelly@gmail.com> - 2014-05-14 13:30 -0600
                      Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-13 20:08 +0100
              Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Ian Kelly <ian.g.kelly@gmail.com> - 2014-05-11 18:02 -0600
                Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-12 09:02 -0700
          Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Terry Reedy <tjreedy@udel.edu> - 2014-05-11 19:49 -0400
            Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-12 09:17 -0700
      Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Chris Angelico <rosuav@gmail.com> - 2014-05-12 11:40 +1000
    Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Rustom Mody <rustompmody@gmail.com> - 2014-05-11 19:47 -0700
      Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions. Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-05-12 09:23 -0700

Page 2 of 3 — ← Prev page 1 [2] 3  Next page →


#71476

FromSimon Evans <musicalhacksaw@yahoo.co.uk>
Date2014-05-13 04:59 -0700
Message-ID<81acc9a1-f3d5-4379-9b29-1be4966f6c35@googlegroups.com>
In reply to#71403
Dear Ian,  and other programmers, thank you for your advice. 
I am resending the last message because this twattish cut and paste facility on my computer has a knack of chopping off ones original message, I will try to convey the right message this time :  

I have removed the original Beautiful Soup 4 download, that I had unzipped to my Beautiful Soup directory on the C drive. 
I downloaded the latest version of Beautiful Soup 4 from the Crummy site. 
I unzipped it, and removed the contents of the unzipped directory and placed contents in my Beautiful Soup directory, and again had the same output to my console re: 
-------------------------------------------------------------------------------- 

Microsoft Windows [Version 6.1.7601] 
Copyright (c) 2009 Microsoft Corporation.  All rights reserved. 

C:\Users\Intel Atom>cd "c:\Beautiful Soup" 

c:\Beautiful Soup>c:\Python27\python setup.py install 

running install
running build
running build_py
error: package directory 'bs4' does not exist


c:\Beautiful Soup> 
------------------------------------------------------------------------------- 
I have made a note of all the contents of the downloaded and unzipped BS4,ie the contents of my Beautiful Soup folder on the C drive, which is as follows: 
------------------------------------------------------------------------------- 

running install 
running build 
running build_py 

error: package directory 'bs4' does not existinit 
_html5lib 
_htmlparser 
_lxml 
6.1 
AUTHORS 
conf 
COPYING 
dammit 
demonstration_markup 
element 
index.rst 
Makefile 
NEWS 
PGK-INFO 
README 
setup 
test_builder_registry 
test_docs 
test_html5lib 
test_htmlparser 
text_lxml 
test_soup 
test_tree 
testing 
TODO 
-------------------------------------------------------------------------------- 
I can see no bs4 folder within the contents. 
 I can not see any setup.py file either, but this is how I downloaded it. 
I am only following instructions as suggested. 
I do not understand why it is not working. 
I hope someone can direct me in the right direction, as I seem to be stuck, and I don't think it has much bearing on my fluency or lack of it with Python. 

[toc] | [prev] | [next] | [standalone]


#71482

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2014-05-13 14:23 +0100
Message-ID<mailman.9963.1399987429.18130.python-list@python.org>
In reply to#71476
On 13/05/2014 12:59, Simon Evans wrote:

I suggest that you follow the instructions here 
http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows 
to get pip, then let pip do the work for you as that's what it's 
designed for :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#71498

FromMRAB <python@mrabarnett.plus.com>
Date2014-05-13 15:48 +0100
Message-ID<mailman.9971.1399992537.18130.python-list@python.org>
In reply to#71476
On 2014-05-13 12:59, Simon Evans wrote:
> Dear Ian,  and other programmers, thank you for your advice.
> I am resending the last message because this twattish cut and paste facility on my computer has a knack of chopping off ones original message, I will try to convey the right message this time :
>
> I have removed the original Beautiful Soup 4 download, that I had unzipped to my Beautiful Soup directory on the C drive.
> I downloaded the latest version of Beautiful Soup 4 from the Crummy site.
> I unzipped it, and removed the contents of the unzipped directory and placed contents in my Beautiful Soup directory, and again had the same output to my console re:
> --------------------------------------------------------------------------------
>
> Microsoft Windows [Version 6.1.7601]
> Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
>
> C:\Users\Intel Atom>cd "c:\Beautiful Soup"
>
> c:\Beautiful Soup>c:\Python27\python setup.py install
>
> running install
> running build
> running build_py
> error: package directory 'bs4' does not exist
>
>
> c:\Beautiful Soup>
> -------------------------------------------------------------------------------
> I have made a note of all the contents of the downloaded and unzipped BS4,ie the contents of my Beautiful Soup folder on the C drive, which is as follows:
> -------------------------------------------------------------------------------
>
> running install
> running build
> running build_py
>
> error: package directory 'bs4' does not existinit
> _html5lib
> _htmlparser
> _lxml
> 6.1
> AUTHORS
> conf
> COPYING
> dammit
> demonstration_markup
> element
> index.rst
> Makefile
> NEWS
> PGK-INFO
> README
> setup
> test_builder_registry
> test_docs
> test_html5lib
> test_htmlparser
> text_lxml
> test_soup
> test_tree
> testing
> TODO
> --------------------------------------------------------------------------------
> I can see no bs4 folder within the contents.
>   I can not see any setup.py file either, but this is how I downloaded it.
> I am only following instructions as suggested.
> I do not understand why it is not working.
> I hope someone can direct me in the right direction, as I seem to be stuck, and I don't think it has much bearing on my fluency or lack of it with Python.
>

I think I see your problem: you've unpacked everything into a single
folder instead of a folder hierarchy.

(It also looks like you have Explorer configured to hide the file
extensions. That's generally _not_ recommended.)


Try this:

#! python3.4
# -*- coding: utf-8 -*-
from os.path import splitext
import gzip
import tarfile

# The path of the downloaded file.
tar_gz_path = r'C:\beautifulsoup4-4.3.2.tar.gz'

# Unpack the .tar.gz file to a .tar file.
tar_path, ext = splitext(tar_gz_path)

with gzip.open(tar_gz_path, 'rb') as from_file:
     with open(tar_path, 'wb') as to_file:
         chunk = from_file.read()
         to_file.write(chunk)

# Unpack the .tar file to a folder.
folder, ext = splitext(tar_path)

tar = tarfile.open(tar_path)
tar.extractall(folder)
tar.close()

[toc] | [prev] | [next] | [standalone]


#71574

FromSimon Evans <musicalhacksaw@yahoo.co.uk>
Date2014-05-14 12:28 -0700
Message-ID<a187e566-50b9-40d7-b8f1-b10c51dec591@googlegroups.com>
In reply to#71498
I have input the above code by copy and pasting to the Idle python console, as the python 2.7 command prompt is fussy about the indentation on the eleventh line down, if I then indent it, it replies that the indentation is unnecessary of unexpected, and if I don't it says an indentation is expected. 
However when I get to the next lines of code - in the Idle prompt re:

C:\Users\Intel Atom>cd "c:\Beautiful Soup"

c:\Beautiful Soup>c:\Python27\python setup.py install

Again it does not recognise 'bs4'. I think having used 'Just unzip it' instead of 'WinZip' may have caused this problem, in the first place ,as when I looked at the WinZip version at a local net café, it did have a folder hierarchy, however I wanted, and still want to skimp the £25 fee for WinZip, which nowadays you can't seem to be able to do. I never asked for the darn files to be zipped, so why ought I pay to have them unzipped, being my contention.

[toc] | [prev] | [next] | [standalone]


#71576

FromIan Kelly <ian.g.kelly@gmail.com>
Date2014-05-14 13:33 -0600
Message-ID<mailman.10019.1400096064.18130.python-list@python.org>
In reply to#71574
On Wed, May 14, 2014 at 1:28 PM, Simon Evans > Again it does not
recognise 'bs4'. I think having used 'Just unzip it' instead of
'WinZip' may have caused this problem, in the first place ,as when I
looked at the WinZip version at a local net café, it did have a folder
hierarchy, however I wanted, and still want to skimp the £25 fee for
WinZip, which nowadays you can't seem to be able to do. I never asked
for the darn files to be zipped, so why ought I pay to have them
unzipped, being my contention.

I use 7-zip (www.7-zip.org), which is freely distributed and open source.

[toc] | [prev] | [next] | [standalone]


#71577

FromChris Angelico <rosuav@gmail.com>
Date2014-05-15 05:36 +1000
Message-ID<mailman.10020.1400096224.18130.python-list@python.org>
In reply to#71574
On Thu, May 15, 2014 at 5:33 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> I use 7-zip (www.7-zip.org), which is freely distributed and open source.

You beat me to the punch. :) Was about to say the exact same thing, so
instead I'll second your recommendation.

ChrisA

[toc] | [prev] | [next] | [standalone]


#71590

FromSimon Evans <musicalhacksaw@yahoo.co.uk>
Date2014-05-15 02:22 -0700
Message-ID<167bfe35-c36b-4d9d-8bd3-810015b24af6@googlegroups.com>
In reply to#71577
Dear Programmers,
I downloaded Peazip, which doesn't remove file/ folder hierarchy. I unzipped it and input the same code to the console and it installed Beautiful Soup 4 okay re:- 
---------------------------------------------------------------------------------
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Intel Atom>cd "c:\Beautiful Soup"

c:\Beautiful Soup>c:\Python27\python setup.py install
running install
running build
running build_py
creating build
creating build\lib
creating build\lib\bs4
copying bs4\dammit.py -> build\lib\bs4
copying bs4\element.py -> build\lib\bs4
copying bs4\testing.py -> build\lib\bs4
copying bs4\__init__.py -> build\lib\bs4
creating build\lib\bs4\builder
copying bs4\builder\_html5lib.py -> build\lib\bs4\builder
copying bs4\builder\_htmlparser.py -> build\lib\bs4\builder
copying bs4\builder\_lxml.py -> build\lib\bs4\builder
copying bs4\builder\__init__.py -> build\lib\bs4\builder
creating build\lib\bs4\tests
copying bs4\tests\test_builder_registry.py -> build\lib\bs4\tests
copying bs4\tests\test_docs.py -> build\lib\bs4\tests
copying bs4\tests\test_html5lib.py -> build\lib\bs4\tests
copying bs4\tests\test_htmlparser.py -> build\lib\bs4\tests
copying bs4\tests\test_lxml.py -> build\lib\bs4\tests
copying bs4\tests\test_soup.py -> build\lib\bs4\tests
copying bs4\tests\test_tree.py -> build\lib\bs4\tests
copying bs4\tests\__init__.py -> build\lib\bs4\tests
running install_lib
creating c:\Python27\Lib\site-packages\bs4
creating c:\Python27\Lib\site-packages\bs4\builder
copying build\lib\bs4\builder\_html5lib.py -> c:\Python27\Lib\site-packages\bs4\
builder
copying build\lib\bs4\builder\_htmlparser.py -> c:\Python27\Lib\site-packages\bs
4\builder
copying build\lib\bs4\builder\_lxml.py -> c:\Python27\Lib\site-packages\bs4\buil
der
copying build\lib\bs4\builder\__init__.py -> c:\Python27\Lib\site-packages\bs4\b
uilder
copying build\lib\bs4\dammit.py -> c:\Python27\Lib\site-packages\bs4
copying build\lib\bs4\element.py -> c:\Python27\Lib\site-packages\bs4
copying build\lib\bs4\testing.py -> c:\Python27\Lib\site-packages\bs4
creating c:\Python27\Lib\site-packages\bs4\tests
copying build\lib\bs4\tests\test_builder_registry.py -> c:\Python27\Lib\site-pac
kages\bs4\tests
copying build\lib\bs4\tests\test_docs.py -> c:\Python27\Lib\site-packages\bs4\te
sts
copying build\lib\bs4\tests\test_html5lib.py -> c:\Python27\Lib\site-packages\bs
4\tests
copying build\lib\bs4\tests\test_htmlparser.py -> c:\Python27\Lib\site-packages\
bs4\tests
copying build\lib\bs4\tests\test_lxml.py -> c:\Python27\Lib\site-packages\bs4\te
sts
copying build\lib\bs4\tests\test_soup.py -> c:\Python27\Lib\site-packages\bs4\te
sts
copying build\lib\bs4\tests\test_tree.py -> c:\Python27\Lib\site-packages\bs4\te
sts
copying build\lib\bs4\tests\__init__.py -> c:\Python27\Lib\site-packages\bs4\tes
ts
copying build\lib\bs4\__init__.py -> c:\Python27\Lib\site-packages\bs4
byte-compiling c:\Python27\Lib\site-packages\bs4\builder\_html5lib.py to _html5l
ib.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\builder\_htmlparser.py to _html
parser.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\builder\_lxml.py to _lxml.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\builder\__init__.py to __init__
.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\dammit.py to dammit.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\element.py to element.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\testing.py to testing.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\tests\test_builder_registry.py
to test_builder_registry.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\tests\test_docs.py to test_docs
.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\tests\test_html5lib.py to test_
html5lib.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\tests\test_htmlparser.py to tes
t_htmlparser.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\tests\test_lxml.py to test_lxml
.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\tests\test_soup.py to test_soup
.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\tests\test_tree.py to test_tree
.pyc
byte-compiling c:\Python27\Lib\site-packages\bs4\tests\__init__.py to __init__.p
yc
byte-compiling c:\Python27\Lib\site-packages\bs4\__init__.py to __init__.pyc
running install_egg_info
Writing c:\Python27\Lib\site-packages\beautifulsoup4-4.1.0-py2.7.egg-info

c:\Beautiful Soup>
--------------------------------------------------------------------------------
Thank you for your thoughtful help, I am sure I will be needing more though, in the not too distant future. 

[toc] | [prev] | [next] | [standalone]


#71591

FromSimon Evans <musicalhacksaw@yahoo.co.uk>
Date2014-05-15 04:25 -0700
Message-ID<e24f1d40-3f1a-42f7-9650-afffa4855754@googlegroups.com>
In reply to#71590

Dear Programmers,
As anticipated, it has not been to long before I have encountered further 

difficulty. At the top of page 16 of 'Getting Started with Beautiful Soup" it 

gives code to be input, whether to the Python or Windows command prompt I am not 

sure, but both seem to be resistant to it. I quote the response to the code below, 

the code input being :- 

helloworld = "<p>Hello World</p>"
soup_string = BeautifulSoup(helloworld)

to Windows Command prompt this gives :- 
----------------------------------------------------------------------------------
SyntaxError: invalid syntax
>>> helloworld = "<p>HelloWorld</p>"
>>> soup_string = BeautifulSoup(helloworld)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'BeautifulSoup' is not defined
----------------------------------------------------------------------------------
I have been told by one of the programmers, that I ought be inputting this to the 

Python command prompt (the book doesn't spacify), but that doesn't take either 

re:-
----------------------------------------------------------------------------------
>>>helloworld = <p>HelloWorld</p>"
>>>soup_string = BeautifulSoup(helloworld)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'BeautifulSoup' is not defined
>>>
----------------------------------------------------------------------------------
Looking at the bottom of page 16, there is more code for the inputting of, that 

again does not take to the Windows Command Prompt or the Python command prompt,
re:  import urllib2
     from bs4 import BeautifulSoup
     url = "http://www.packtpub.com/books"
     page = urllib2.urlopen(url)
     soup_packtpage = BeautifulSoup(page)

returns to the Windows Command prompt:- 
----------------------------------------------------------------------------------
>>>import urllib2
Traceback (most recent call last):
  File "<stdin>", line1, in <module>
ImportError: No module named 'urllib2'
>>>

----------------------------------------------------------------------------------
returns to the Python command prompt :- 
----------------------------------------------------------------------------------
>>> import urllib2
>>> from bs4 import BeautifulSoup
>>> url = "http://www.packtpub.com/books"
>>> page = urllib2.urlopen(url)
Traceback (most recent call last):
File "C\Python27\lib\urllib2.py",line 127, in urlopen
  return_opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py",line 410, in open
response = meth(req, response)
File "C:\Pyton27\lib\urllib2.py", oine 523, in http_response
'http', request, response, code, msg, hdrs)
File"C:\Python27\lib\urllib2.py", line 448, in error
return self._call_chain(*args)
File "C:/Python27/lib/urllib2.py",line 382, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 531, in http_error_default
raise HTTPError(req.get_full_url(), code, masg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden
---------------------------------------------------------------------------------
Anway I hope you can tell me what is amiss, there is no point in my proceeding 

with the book (about 111 pages all told) until I find out why it won't take. 
I realise I have been told to learn python in order to make things less painful, 

but I don't see why code written in the book does not take. 
Thank you for reading.





I thought I might as well include, so's you might be able to see where things are 

going astray. The Windows command prompt :- 


[toc] | [prev] | [next] | [standalone]


#71592

FromSimon Evans <musicalhacksaw@yahoo.co.uk>
Date2014-05-15 04:30 -0700
Message-ID<85a05ee8-9f79-4cd2-875f-4926d11e9639@googlegroups.com>
In reply to#71591
Dear Programmers, I noticed a couple of typos in my previous message, so have now altered them thus :- 

Dear Programmers,
As anticipated, it has not been to long before I have encountered further 

difficulty. At the top of page 16 of 'Getting Started with Beautiful Soup" it 

gives code to be input, whether to the Python or Windows command prompt I am not 

sure, but both seem to be resistant to it. I quote the response to the code below, 

the code input being :- 

helloworld = "<p>Hello World</p>"
soup_string = BeautifulSoup(helloworld)

to Windows Command prompt this gives :- 
----------------------------------------------------------------------------------
SyntaxError: invalid syntax
>>> helloworld = "<p>HelloWorld</p>"
>>> soup_string = BeautifulSoup(helloworld)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'BeautifulSoup' is not defined
----------------------------------------------------------------------------------
I have been told by one of the programmers, that I ought be inputting this to the 

Python command prompt (the book doesn't spacify), but that doesn't take either 

re:-
----------------------------------------------------------------------------------
>>>helloworld = <p>HelloWorld</p>"
>>>soup_string = BeautifulSoup(helloworld)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'BeautifulSoup' is not defined
>>>
----------------------------------------------------------------------------------
Looking at the bottom of page 16, there is more code for the inputting of, that 

again does not take to the Windows Command Prompt or the Python command prompt,
re:  import urllib2
     from bs4 import BeautifulSoup
     url = "http://www.packtpub.com/books"
     page = urllib2.urlopen(url)
     soup_packtpage = BeautifulSoup(page)

returns to the Windows Command prompt:- 
----------------------------------------------------------------------------------
>>>import urllib2
Traceback (most recent call last):
  File "<stdin>", line1, in <module>
ImportError: No module named 'urllib2'
>>>

----------------------------------------------------------------------------------
returns to the Python command prompt :- 
----------------------------------------------------------------------------------
>>> import urllib2
>>> from bs4 import BeautifulSoup
>>> url = "http://www.packtpub.com/books"
>>> page = urllib2.urlopen(url)
Traceback (most recent call last):
File "C\Python27\lib\urllib2.py",line 127, in urlopen
  return_opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py",line 410, in open
response = meth(req, response)
File "C:\Python27\lib\urllib2.py", oine 523, in http_response
'http', request, response, code, msg, hdrs)
File"C:\Python27\lib\urllib2.py", line 448, in error
return self._call_chain(*args)
File "C:/Python27/lib/urllib2.py",line 382, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 531, in http_error_default
raise HTTPError(req.get_full_url(), code, masg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden
---------------------------------------------------------------------------------
Anway I hope you can tell me what is amiss, there is no point in my proceeding 

with the book (about 111 pages all told) until I find out why it won't take. 
I realise I have been told to learn python in order to make things less painful, 

but I don't see why code written in the book does not take. 
Thank you for reading.








 

[toc] | [prev] | [next] | [standalone]


#71593

FromDave Angel <davea@davea.name>
Date2014-05-15 08:12 -0400
Message-ID<mailman.10031.1400155978.18130.python-list@python.org>
In reply to#71592
On 05/15/2014 07:30 AM, Simon Evans wrote:
> Dear Programmers, I noticed a couple of typos in my previous message, so have now altered them thus :-
>
> Dear Programmers,
> As anticipated, it has not been to long before I have encountered further
>
> difficulty.

Your first thread was about getting Beautiful Soup installed and 
working.  If you can successfully import it, you're ready for a new 
thread, new subject line, etc.

Note the new thread's opener should be self-contained, meaning you 
should mention the environment (version of BS, version of Python, 
version of what OS), and your difficulty.

 > At the top of page 16 of 'Getting Started with Beautiful Soup" it
 >
 > gives code to be input, whether to the Python or Windows command 
prompt I am not
 >


My guess is that the book is now describing what goes in a program, not 
at the "command prompts".  A program is typically written in a text 
file, not at the interpreter prompt, though experimentation is certainly 
done there.

Once you have a program in a text file (usually with the extension .py), 
you run it at the OS terminal prompt by typing:
      python  myprogram.py





-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#71595

FromRustom Mody <rustompmody@gmail.com>
Date2014-05-15 05:17 -0700
Message-ID<d8f316d0-a471-4aa7-91c1-f7f69052f2fe@googlegroups.com>
In reply to#71591
On Thursday, May 15, 2014 4:55:42 PM UTC+5:30, Simon Evans wrote:
> Dear Programmers,
> 
> As anticipated, it has not been to long before I have encountered further 
> 
> difficulty. At the top of page 16 of 'Getting Started with Beautiful Soup" it 
> 
> gives code to be input, whether to the Python or Windows command prompt I am not 
> 
> sure, but both seem to be resistant to it. I quote the response to the code below, 

It was because I thought I saw such a mixup in your earlier posts that
I suggested you start with the python tutorial :-)
> Looking at the bottom of page 16, there is more code for the inputting of, that 
> 
> 
> 
> again does not take to the Windows Command Prompt or the Python command prompt,
> 
> re:  import urllib2
> 
>      from bs4 import BeautifulSoup

You probably need the above line
And you need to preceded the other lines at the python (not shell) prompt

On the whole it may be a good idea to put aside the book and just follow the quick start http://www.crummy.com/software/BeautifulSoup/bs4/doc/#quick-start

at the python prompt

> 
>      url = "http://www.packtpub.com/books"
> 
>      page = urllib2.urlopen(url)
> 
>      soup_packtpage = BeautifulSoup(page)
> 
> 
> 
> returns to the Windows Command prompt:- 
> 
> ----------------------------------------------------------------------------------
> 
> >>>import urllib2
> 
> Traceback (most recent call last):
> 
>   File "<stdin>", line1, in <module>
> 
> ImportError: No module named 'urllib2'
> 
> >>>
> 
> 
> 
> ----------------------------------------------------------------------------------
> 
> returns to the Python command prompt :- 
> 
> ----------------------------------------------------------------------------------
> 
> >>> import urllib2
> 
> >>> from bs4 import BeautifulSoup
> 
> >>> url = "http://www.packtpub.com/books"
> 
> >>> page = urllib2.urlopen(url)
> 
> Traceback (most recent call last):
> 
> File "C\Python27\lib\urllib2.py",line 127, in urlopen
> 
>   return_opener.open(url, data, timeout)
> 
> File "C:\Python27\lib\urllib2.py",line 410, in open
> 
> response = meth(req, response)
> 
> File "C:\Pyton27\lib\urllib2.py", oine 523, in http_response
> 
> 'http', request, response, code, msg, hdrs)
> 
> File"C:\Python27\lib\urllib2.py", line 448, in error
> 
> return self._call_chain(*args)
> 
> File "C:/Python27/lib/urllib2.py",line 382, in _call_chain
> 
> result = func(*args)
> 
> File "C:\Python27\lib\urllib2.py", line 531, in http_error_default
> 
> raise HTTPError(req.get_full_url(), code, masg, hdrs, fp)
> 
> urllib2.HTTPError: HTTP Error 403: Forbidden
> 
> ---------------------------------------------------------------------------------
> 
> Anway I hope you can tell me what is amiss, there is no point in my proceeding 
> 
> 
> 
> with the book (about 111 pages all told) until I find out why it won't take. 
> 
> I realise I have been told to learn python in order to make things less painful, 
> 
> 
> 
> but I don't see why code written in the book does not take. 
> 
> Thank you for reading.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> I thought I might as well include, so's you might be able to see where things are 
> 
> 
> 
> going astray. The Windows command prompt :-

[toc] | [prev] | [next] | [standalone]


#71501

FromIan Kelly <ian.g.kelly@gmail.com>
Date2014-05-13 10:33 -0600
Message-ID<mailman.9973.1399998868.18130.python-list@python.org>
In reply to#71476
On Tue, May 13, 2014 at 5:59 AM, Simon Evans <musicalhacksaw@yahoo.co.uk> wrote:
> I can see no bs4 folder within the contents.
> I can not see any setup.py file either, but this is how I downloaded it.

You do have a setup.py in there, but your Windows explorer is showing
it to you without the .py extension.  Something unusual is happening
with the download/extraction process though and you're missing the
correct folder structure.  If you take a look here, you can see what
you *should* have after unzipping:

http://bazaar.launchpad.net/~leonardr/beautifulsoup/bs4/files

This approach seems to be unproductive though, so I'm going to second
Mark's suggestion to just use pip:

1) Go to pip-installer.org and download the single file get-pip.py
2) Open a command prompt and cd to the folder you downloaded that file into.
3) python get-pip.py
4) pip install beautifulsoup4

And then you should finally be ready to get started.  Good luck!

[toc] | [prev] | [next] | [standalone]


#71573

FromSimon Evans <musicalhacksaw@yahoo.co.uk>
Date2014-05-14 11:58 -0700
Message-ID<11010ab5-4bce-4d39-8d36-a010911f7090@googlegroups.com>
In reply to#71501
I downloaded the get-pip.py file. I installed it to the same folder on my C drive as the Beautiful Soup one in which the Beautiful Soup 4 downloads was unzipped to. I changed directory to the folder on the Command Prompt, as you instructed in step 2. I input the code to the console you gave on step 3), that returned some code, as quoted below. I then input the code you gave on step 4) but Console seems to reject or not recognise 'pip' as a term. I am sure quoting the actual prompt response can explain things better than I :
-------------------------------------------------------------------------------
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.


C:\Users\Intel Atom>cd "c:\Beautiful Soup"

c:\Beautiful Soup>python get-pip.py
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pi
p-1.5.5-py2.py3-none-any.whl#md5=03a932d6f82a3887d8de1cdb837c87ed
Installing collected packages: pip
  Found existing installation: pip 1.5.4
    Uninstalling pip:
      Successfully uninstalled pip
Successfully installed pip
Cleaning up...

c:\Beautiful Soup>pip install beautifulsoup4
'pip' is not recognized as an internal or external command,
operable program or batch file.

c:\Beautiful Soup>
--------------------------------------------------------------------------------
Perhaps I oughtn't have downloaded the pip file to the same directory as the Beautiful Soup ? I will have a try at transferring the file to another folder
and running the code you gave again. 

[toc] | [prev] | [next] | [standalone]


#71575

FromIan Kelly <ian.g.kelly@gmail.com>
Date2014-05-14 13:30 -0600
Message-ID<mailman.10018.1400095896.18130.python-list@python.org>
In reply to#71573
On Wed, May 14, 2014 at 12:58 PM, Simon Evans
<musicalhacksaw@yahoo.co.uk> wrote:
> c:\Beautiful Soup>pip install beautifulsoup4
> 'pip' is not recognized as an internal or external command,
> operable program or batch file.
>
> c:\Beautiful Soup>
> --------------------------------------------------------------------------------
> Perhaps I oughtn't have downloaded the pip file to the same directory as the Beautiful Soup ? I will have a try at transferring the file to another folder
> and running the code you gave again.

No, sounds like a path environment variable issue.  The python
executable is on your path, but the pip executable is not.  The
get-pip.py script should have installed it into C:\Python27\Scripts, I
think, so either add that directory to your path (you can find
instructions for this on the web) or just cd to that directory and run
the pip command from there.

[toc] | [prev] | [next] | [standalone]


#71508

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2014-05-13 20:08 +0100
Message-ID<mailman.9978.1400008137.18130.python-list@python.org>
In reply to#71476
On 13/05/2014 17:33, Ian Kelly wrote:
> On Tue, May 13, 2014 at 5:59 AM, Simon Evans <musicalhacksaw@yahoo.co.uk> wrote:
>> I can see no bs4 folder within the contents.
>> I can not see any setup.py file either, but this is how I downloaded it.
>
> You do have a setup.py in there, but your Windows explorer is showing
> it to you without the .py extension.  Something unusual is happening
> with the download/extraction process though and you're missing the
> correct folder structure.  If you take a look here, you can see what
> you *should* have after unzipping:
>
> http://bazaar.launchpad.net/~leonardr/beautifulsoup/bs4/files
>
> This approach seems to be unproductive though, so I'm going to second
> Mark's suggestion to just use pip:
>
> 1) Go to pip-installer.org and download the single file get-pip.py
> 2) Open a command prompt and cd to the folder you downloaded that file into.
> 3) python get-pip.py
> 4) pip install beautifulsoup4
>
> And then you should finally be ready to get started.  Good luck!
>

To be fair Terry Reedy has suggested pip at least twice, I've just given 
another source of data on how to get pip in the first place.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#71356

FromIan Kelly <ian.g.kelly@gmail.com>
Date2014-05-11 18:02 -0600
Message-ID<mailman.9901.1399853015.18130.python-list@python.org>
In reply to#71349
On Sun, May 11, 2014 at 5:47 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> Also, use Python 3.4 as Terry Reedy suggested, unless the book is
> using 2.7 in which case you should probably use the same version as
> the book.

Following up on that, if this is the book you are using:
http://www.amazon.com/Getting-Started-Beautiful-Soup-Vineeth/dp/1783289554

then it says to use Python 2.7.5 or greater.  There is no indication
that the book is targeted at Python 3, and in fact I see at least one
line that won't work in Python 3 ("import urllib2"), so I definitely
recommend sticking with a 2.7 release.

[toc] | [prev] | [next] | [standalone]


#71390

FromSimon Evans <musicalhacksaw@yahoo.co.uk>
Date2014-05-12 09:02 -0700
Message-ID<fc629f48-d4c2-4710-83ad-02c92fd0e8d7@googlegroups.com>
In reply to#71356
Hi Ian, thank you for your help. 
Yes that is the book by Vineeth J Nair.
At the top of page 12, at step 1 it says :

1.Download the latest tarball from https://pypi.python.org/packages/source/b/beautifulsoup4/.

So yes, the version the book is dealing with is beautiful soup 4. 
I am using Pyhon 2.7, I have removed Python 3.4.
Also on the bottom of page 10, Mr Nair states:

Pick the path variagble and add the following section to the Path variable:

;C:\PythonXY for example C:\Python27

Which tells me that the Python version cited in the book must be 2.7

I downloaded beautiful soup 4 last night. I unzipped it with 'Just unzip it' to a folder I called Beautiful Soup, the same as I did with the previous beautiful soup download. The console return is as below, showing that I am now facing the same conundrum as yesterday, before changing my version of Beautiful Soup. re:
--------------------------------------------------------------------------------
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Intel Atom>cd "c:\Beautiful Soup"

c:\Beautiful Soup>Beautiful Soup>c:\Python27\python setup.py install
'Beautiful' is not recognized as an internal or external command,
operable program or batch file.

c:\Beautiful Soup>

[toc] | [prev] | [next] | [standalone]


#71352

FromTerry Reedy <tjreedy@udel.edu>
Date2014-05-11 19:49 -0400
Message-ID<mailman.9899.1399852176.18130.python-list@python.org>
In reply to#71345
On 5/11/2014 6:03 PM, Simon Evans wrote:
> I have downloaded Beautiful Soup 3, I am using Python 2.7. I
> understand from your message that I ought to use Python 2.6or Python
> 3.4 with Beautiful Soup 4,

I wrote "BeautifulSoup4 works with 2.6+ and 3.x.".
'2.6+' means 2.6 or 2.7. '3.x' should mean 3.1 to 3.4 but the range 
might start later. It does not matter because you should download and 
use 3.4 unless you *really* need to use something earlier. But also note 
that Windows has no problem with multiple version of python installed in 
different pythonxy directories.

One of the things 3.4 does for you is make sure that pip is installed. 
It is now the more or less 'official' python package installer. To 
install BS4, do what the authors recommend on their web page
http://www.crummy.com/software/BeautifulSoup/
and what I did: 'pip install beautifulsoup4' in a python34 directory. It 
took me less than a minute, far less that it took you to report that 
doing something else did not work.

-- 
Terry Jan Reedy

[toc] | [prev] | [next] | [standalone]


#71391

FromSimon Evans <musicalhacksaw@yahoo.co.uk>
Date2014-05-12 09:17 -0700
Message-ID<e4dd9dca-2c73-458e-b0a5-8502f39234e5@googlegroups.com>
In reply to#71352
The version of Python the book seems to be referring to is 2.7, re: bottom of page 10-
'Pick the Path variable and add the following section to the Path variable: ;C:\PythonXY for example C:\Python 27'

The version of Beautiful Soup seems to be Beautiful Soup 4 as at the top of page 12 it states:
'1.Download the latest tarball from https://pypi.python.org/packages/source/b/beautifulsoup4/.'

I have downloaded and unzipped to a folder called 'Beautiful Soup' on the C drive the Beautiful Soup 4 version. I am using the Python 2.7 console and IDLE, I have removed the 3.4 version. 

All the same I seem to be having difficulties again as console wont accept the code it did when it was the previous version of BS that I used yesterday. I realise I would not be having this problem if I proceeded to input the 'Hello World' code on the Python console, but as said, the text never specifically said 'change to Python 2.7 console'. I thought the problem was with the BS version and so changed it, but now can't even get as far as I had before changing it. Anyhow be that as it may, this is the console response to my input:
--------------------------------------------------------------------------------
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Intel Atom>cd "c:\Beautiful Soup"

c:\Beautiful Soup>Beautiful Soup>c:\Python27\python setup.py install
'Beautiful' is not recognized as an internal or external command,
operable program or batch file.

c:\Beautiful Soup>

[toc] | [prev] | [next] | [standalone]


#71361

FromChris Angelico <rosuav@gmail.com>
Date2014-05-12 11:40 +1000
Message-ID<mailman.9904.1399858832.18130.python-list@python.org>
In reply to#71338
On Mon, May 12, 2014 at 6:31 AM, Terry Reedy <tjreedy@udel.edu> wrote:
> Please do not advise people to unnecessarily downgrade to 2.7 ;-).
> Simon just needs the proper current version of BeautifulSoup.
> BeautifulSoup3 does not work with 3.x.
> BeautifulSoup4 works with 2.6+ and 3.x.
> http://www.crummy.com/software/BeautifulSoup/
> Installation (of the latest version on PyPI) is trivial with 3.4:

Oh, I'm glad of that! But without digging into the details of BS, all
I could say for sure was that setup.py was expecting 2.x. :)

Sticking with 3.4 and upgrading to BS4 is a much better solution.

ChrisA

[toc] | [prev] | [next] | [standalone]


Page 2 of 3 — ← Prev page 1 [2] 3  Next page →

Back to top | Article view | comp.lang.python


csiph-web