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()

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to