What's the best way to write this regular expression?

I

Ian Kelly

Ok, first major roadblock. I have no idea how to install Beautiful
Soup or lxml on Windows! All I can find are .tar files. Based on what
I've read, I can use the easy_setup module to install these types of
files, but when I went to download the setuptools package, it only
seemed to support Python 2.7. I'm using 3.2. Is 2.7 just the minimum
version it requires? It didn't say something like "2.7+", so I wasn't
sure, and I don't want to start installing a bunch of stuff that will
clog up my directories and not even work.

There is a fork of setuptools called "distribute" that supports Python 3.
What's the best way for me to install these two packages? I've also
seen a reference to using setup.py...is that a separate package too,
or is that something that comes with Python by default?

setup.py is a file that should be included at the top-level of the
..tar files you downloaded. Generally, to install something in that
manner, you would navigate to that top-level folder and run "python
setup.py install". If you have multiple Python versions installed and
want to install the package for a specific version, then you would use
that version of Python to run the setup.py file.
 
J

John Salerno

There is a fork of setuptools called "distribute" that supports Python 3.

Thanks, I guess I'll give this a try tonight!
setup.py is a file that should be included at the top-level of the
.tar files you downloaded.  Generally, to install something in that
manner, you would navigate to that top-level folder and run "python
setup.py install".  If you have multiple Python versions installed and
want to install the package for a specific version, then you would use
that version of Python to run the setup.py file.

The only files included in the .tar.gz file is a .tar file of the same
name. So I guess the setup option doesn't exist for these particular
packages. I'll try "distribute" tonight when I have some time to mess
with all of this.

So much work just to get a 3rd party module installed!
 
B

Benjamin Kaplan

Thanks, I guess I'll give this a try tonight!


The only files included in the .tar.gz file is a .tar file of the same
name. So I guess the setup option doesn't exist for these particular
packages. I'll try "distribute" tonight when I have some time to mess
with all of this.

So much work just to get a 3rd party module installed!
--


It's because your extraction program is weird. Gzip is a compression
algorithm that operates on a single file. Tar is an archive format
that combines multiple files into a single file. When we say "extract
the .tar.gz", what we mean is both uncompress the tar file and then
extract everything out of that. A lot of programs will do that in one
step. If you look inside the tar file, you should find the setup.py.
 
P

Prasad, Ramit

The only files included in the .tar.gz file is a .tar file of the same

gz stands for gzip and is a form of compression (like rar/zip ).
tar stands for a tape archive. It is basically a box that holds the
files. So you need to "unzip" and then "open the box".

Normally programs like WinZip / WinRar / 7-zip will do both in one step
so you do not need to. Not sure what program youare using...

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.
 
I

Ian Kelly

The only files included in the .tar.gz file is a .tar file of the same
name. So I guess the setup option doesn't exist for these particular
packages.

The setup.py file (as well as the other files) would be inside the
..tar file. Unlike a Windows zip file, which does both archival and
compression, Unix files are typically archived and compressed in two
separate steps: "tar" denotes the archival format, and "gz" denotes
the compression format. Some decompression programs are smart enough
to recognize the .tar file and automatically extract it when
decompressing. Others require you to decompress the .gz and extract
the .tar separately -- it sounds like yours is one of the latter.
 
J

John Salerno

The setup.py file (as well as the other files) would be inside the
.tar file.  Unlike a Windows zip file, which does both archival and
compression, Unix files are typically archived and compressed in two
separate steps: "tar" denotes the archival format, and "gz" denotes
the compression format.  Some decompression programs are smart enough
to recognize the .tar file and automatically extract it when
decompressing.  Others require you to decompress the .gz and extract
the .tar separately -- it sounds like yours is one of the latter.

Ah, I see now. After opening the gz file, there was a tar file inside,
and then I just opened that file (I use 7zip for these types) and
there was a whole host of stuff inside. I didn't realize the tar file
itself was an archive, I thought it was the module! ::blush::

Maybe I don't need to mess with the "distribute" utility then, if I
can just run the setup file. I'll try that first and see what happens.

Thanks.
 
E

Evan Driscoll

gz stands for gzip and is a form of compression (like rar/zip ).
tar stands for a tape archive. It is basically a box that holds the
files. So you need to "unzip" and then "open the box".

Normally programs like WinZip / WinRar / 7-zip will do both in one step
so you do not need to. Not sure what program you are using...

I'm not sure what 7-zip you're referring to, because I use 7-zip and
it's always been a two-step process for me...

(Though I can't say I've looked through the preferences dialog for a
"extract .tar.gz files in one go" setting.)

Evan
 
C

Chris Angelico

it only
seemed to support Python 2.7. I'm using 3.2. Is 2.7 just the minimum
version it requires? It didn't say something like "2.7+", so I wasn't
sure, and I don't want to start installing a bunch of stuff that will
clog up my directories and not even work.

Just to clarify: Python 2 and Python 3 are quite different. If
something requires Python 2.7, you cannot assume that it will work
with Python 3.2; anything that supports both branches will usually
list the minimum version of each (eg "2.7 or 3.3").

ChrisA
 
J

John Salerno

Just to clarify: Python 2 and Python 3 are quite different. If
something requires Python 2.7, you cannot assume that it will work
with Python 3.2; anything that supports both branches will usually
list the minimum version of each (eg "2.7 or 3.3").

ChrisA

That's why I asked first, because I got the feeling it did NOT support
Python 3 :)
 
J

John Salerno

I'm not sure what 7-zip you're referring to, because I use 7-zip and
it's always been a two-step process for me...

(Though I can't say I've looked through the preferences dialog for a
"extract .tar.gz files in one go" setting.)

Evan

Same here, because that's what I used. I looked through the settings
but didn't see anything. What seems to happen is that 7-Zip recognizes
the .gz extension and opens that automatically. But then that simply
opens up another window with the .tar file in it, which you have to
then open again.
 
J

John Salerno

Alright, I'm simply lost about how to install these modules. I
extracted the folders from the .tar.gz files and then went into those
folders in my command prompt. I typed:

C:\Python32\python setup.py install

and for a while something was happening (I was doing the lxml one) and
then it stopped with an error that it couldn't find a file. So I have
no idea.

Next I installed the "distribute" module, which seemed to install
okay. But now I don't understand how to use easy_install. Where do I
call it from? What do I do with the .tar.gz files at this point? The
instructions for lxml say to run this command:

easy_install --allow-hosts=lxml.de,*.python.org lxml

but WHERE do I run it? I tried it in the Python directory, and then
further in the lxml site-packages directory, but it doesn't work. What
do I do with it? Where do I put the .tar files?
 
J

John Salerno

Alright, I'm simply lost about how to install these modules. I
extracted the folders from the .tar.gz files and then went into those
folders in my command prompt. I typed:

C:\Python32\python setup.py install

and for a while something was happening (I was doing the lxml one) and
then it stopped with an error that it couldn't find a file. So I have
no idea.

Next I installed the "distribute" module, which seemed to install
okay. But now I don't understand how to use easy_install. Where do I
call it from? What do I do with the .tar.gz files at this point? The
instructions for lxml say to run this command:

easy_install --allow-hosts=lxml.de,*.python.org lxml

but WHERE do I run it? I tried it in the Python directory, and then
further in the lxml site-packages directory, but it doesn't work. What
do I do with it? Where do I put the .tar files?

Well, after a bit of experimentation, I got it to run, but I seem to
have run into the same error as when I used setup.py:

http://i271.photobucket.com/albums/jj138/JohnJSal/lxml_error.png

Now I have no idea what to do.
 
J

John Salerno

Now I have no idea what to do.

Hmph, I suppose I should have more patience. I realized that the
easy_install for lxml only tried to install a binary version, which
doesn't exist for the version it found (the latest, 2.3.3). I just had
to look through the previous versions and find the one with a binary
installation for Windows (2.3) and it was as simple as a single click
to install!

And the easy_install method did work for Beautiful Soup, so I should
be all set now!
 
J

John Gordon

In said:
Well, after a bit of experimentation, I got it to run, but I seem to
have run into the same error as when I used setup.py:

Now I have no idea what to do.

The first error on that screen is that "xslt-config" is not found
as a command.

Try a web search for "xslt-config not found", there seemed to be some
helpful results.
 
D

Dave Angel


Nothing to do with Python, but you'd save us all a lot of space and
bandwidth if you learned how to copy/paste from a Windows cmd window.

If you're just doing it rarely, you can right click on the top bar to
get a menu. I think you want "mark". Then you select the text you'd
like to put in the clipboard.

Alternatively, you can put the console in quick-edit mode (I think it's
called, it's been a long time since I ran Windows). That's an option
you set on one cmd window, and it sticks for future windows.

In quick-edit, you just right-click-drag on the cmd window to select a
rectangle of text. Then you can Ctrl-V to paste it into email, or into
a text editor, or wherever else you need it. Hard to imagine not using
this mode, or its Linux equivalent, which is always available.

If that wasn't clear enough, or it doesn't work for you, somebody will
explain it better. Or ask me, and I'll launch a VirtualBox with Windows
to get you going.
 
J

John Salerno

Thanks, I had no idea about either option, since I don't use the
command prompt very much. Needless to say, the Linux console is much
nicer :)
 
E

Ethan Furman

Dave said:
Nothing to do with Python, but you'd save us all a lot of space and
bandwidth if you learned how to copy/paste from a Windows cmd window.

On Windows XP it is:

Mouse
-----
Right-click on title bar
Left-click on Edit
Left-click on Mark
Right-click and drag to select desired text
<enter> to copy text to clipboard

Keyboard
--------
<alt>-<space>
e
k or <enter>
arrows to move cursor, <shift-arrows> to select text
<enter> to copy text to clipboard

~Ethan~
 
P

Prasad, Ramit

Alternatively, you can put the console in quick-edit mode (I think it's

Actually in quick-edit mode (XP and higher) you just select with
left click and then hit enterwhich copies it to the clipboard.
If you also enable insert mode (not sure if this is Win7 specific)
you can even right click to paste into the console, just like
Linux.

Needless to say, the Linux console is much nicer :)
True.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.
 
D

Dave Angel

Actually in quick-edit mode (XP and higher) you just select with
left click and then hit enter which copies it to the clipboard.
If you also enable insert mode (not sure if this is Win7 specific)
you can even right click to paste into the console, just like
Linux.

True.

I was confusing the left-mouse-drag and the right-click. You are
correct about both the copying and the pasting, and they do both work
from XP onwards.

As I said, I haven't used Windows much in quite a while.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top