Adding wget and/or other modules for Python

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding wget and/or other modules for Python

Tim Graettinger
Hi,

This morning I tried to import an use the wget module for Python.  My test code is below.  When I tried running it, I got this message:

ImportError: No module named wget

After Googling around, it seemed like the usual method is to use a utility, pip, to install new modules.  But given my recollection of the very specific version of Python used by SPSS, I was hesitant to try to upgrade or install anything new (including a new version of Python).  Also, pip does not seem to be installed on my machine previously (i.e., as part of the SPSS Python distribution).  Any recommendations on how to proceed?

Thanks!
-Tim

----- code for wget test in SPSS -------------------

BEGIN PROGRAM PYTHON.
import wget

print('Beginning file download with wget module')

url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/breast-cancer-wisconsin.names'
toLocation = 'W:/RandD/Projects/UCI/Test/breast-cancer-wisconsin.names'
wget.download(url, toLocation)

print('End file download with wget module')

END PROGRAM.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Adding wget and/or other modules for Python

Andy W
It is tough to get pip to work (all Windows stuff for me) with the SPSS
installation, but it is possible. Partly because I tend to have multiple
python's floating around, so you need to have pip work with just the one in
the SPSS directory.

An easier solution I have had is installing the Anaconda distribution, and
then pointing SPSS to that distribution. (And much easier time overall using
conda install than pip, especially for things with compiled code.)



-----
Andy W
[hidden email]
http://andrewpwheeler.wordpress.com/
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Adding wget and/or other modules for Python

Jon Peck
In reply to this post by Tim Graettinger
You have run into an annoying aspect of the Python 2.7 integration.  pip is unfortunately not part of the Python 2.7.7 (I think) distribution installed with Statistics, and that version is not registered, anyway.  pip is included with Python 2.7.14.

To get around this, you will need to do this.
1. Install Python 2.7.14 (current 2.7 version) from python.org., say, in a diretory named c:\python27.
2. Run c:\python27\scripts\pip install wget
3. In your Statistics installation go to Edit > Options > Files and point to c:\python27 as your Python 2.7 version.
4. Restart Statistics and you should be all set.

Python 2.7.14 is fine for using with Statistics.  I tried to get the SPSS-installed Python 2.7 upgraded to the .14 level in the V26 beta period, but it didn't happen.

On Fri, Aug 30, 2019 at 7:01 AM Tim Graettinger <[hidden email]> wrote:
Hi,

This morning I tried to import an use the wget module for Python.  My test code is below.  When I tried running it, I got this message:

ImportError: No module named wget

After Googling around, it seemed like the usual method is to use a utility, pip, to install new modules.  But given my recollection of the very specific version of Python used by SPSS, I was hesitant to try to upgrade or install anything new (including a new version of Python).  Also, pip does not seem to be installed on my machine previously (i.e., as part of the SPSS Python distribution).  Any recommendations on how to proceed?

Thanks!
-Tim

----- code for wget test in SPSS -------------------

BEGIN PROGRAM PYTHON.
import wget

print('Beginning file download with wget module')

url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/breast-cancer-wisconsin.names'
toLocation = 'W:/RandD/Projects/UCI/Test/breast-cancer-wisconsin.names'
wget.download(url, toLocation)

print('End file download with wget module')

END PROGRAM.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Adding wget and/or other modules for Python

Tim Graettinger
In reply to this post by Tim Graettinger
Thanks, Andrew!  I may have to give that a try as well as Jon's approach.  Also checked out your blog - cool stuff!
-Tim

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Adding wget and/or other modules for Python

Tim Graettinger
In reply to this post by Tim Graettinger
Thanks, Jon!  I always appreciate your thoughtful (and useful) replies!!!  I'll give it a whirl.
-Tim

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD