How do I add SPSS to python sys.path?

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

How do I add SPSS to python sys.path?

David Marso
Administrator
I just installed the Anaconda python distribution and trying to use SPSS from
the Spyder IDE.
I tried appending the SPSS main directory as well as the JRE// bin but no
joy.  Must be incredibly simple.



-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: How do I add SPSS to python sys.path?

Jon Peck
Create a sitecustomize.py file in the Anaconda site-customize directory and put your append to sys.path there.  You should also go to Edit > Options > Files in Statistics, and set the directory for Python to the Anaconda directory (either 2.7 or 3.4 depending on which Anaconda you installed).

On Wed, Apr 11, 2018 at 5:42 PM David Marso <[hidden email]> wrote:
I just installed the Anaconda python distribution and trying to use SPSS from
the Spyder IDE.
I tried appending the SPSS main directory as well as the JRE// bin but no
joy.  Must be incredibly simple.



-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
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
--
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: How do I add SPSS to python sys.path?

David Marso
Administrator
Hi Jon, Thanks for the info but no joy

I entered:

sys.path.append("C:\\Program Files\\IBM\\SPSS\\Statistics\\22")
import spss

to the top of the existing sitecustomize.py file located in:


"C:\Users\Owner\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py"

still get
    import spss

ModuleNotFoundError: No module named 'spss'
Should this be pointing to some subdirectory in the SPSS installation?



-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: How do I add SPSS to python sys.path?

David Marso
Administrator
Jon sent me the following off list and  sort of got some things to work:
Actually reexamining the email t looks like the list was also addressed but
I don't see it here. ODD.  THANKS Jon.

"Not the SPSS installation directory.  It should be the
python/lib/site-packages directory under it.  Also, the sitecustomize.py
file should be in the site-packages directory of the Anaconda installation.
Spider might have some of its own logic, so put a print statement in the
file to prove that it was executed or check sys.path before invoking the
spss import."

This as driving me mad because somehow all of my folders became read only
;-((((
Fixed that (sort of).


Now It at least locates the spss path and tries to get up but then falls
down.

  File "C:\Program
Files\IBM\SPSS\Statistics\22\Python\Lib\site-packages\spss\errMsg.py", line
35, in __init__
    self.errMsg = errTable['okay'][str(0)]

KeyError: 'okay'

Probably something simple but the python ecosystem boggles me at the moment.

This is running in python 2.7.
 I would greatly prefer to learn python 3.x but I found there were even more
issues there. Details later after I sort this issue in 2.7



-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: How do I add SPSS to python sys.path?

Jon Peck
There is some really ugly ten-year-old code in the Python code executed on the first import spss, but I have never seen this error before.  I don't have V22, but I don't think the later versions have changed.

So, what I can tell without being able to reproduce this problem is that the initialization code is failing to set up the Python errTable dictionary, and, therefore, when it goes to issue an error message, it can't find its basic string which is, ironically, 'No error.'

The startup code locates the SPSS Python error message file, which is expected to be (for English)
C:\spss24\Python\Lib\site-packages\spss\lang\en\spsspy.properties
in V24 so spss22 or wherever you have V22 installed in your case.

If it doesn't find this file, it raises an exception with message [sic]
Can not find error message file.
and stops

If it does find a file by that name, it reads it and initializes the errTable dictionary from it.  So, if you didn't get the above error message, it would mean that the spsspy.properties file is present but corrupted somehow.  Ignoring comment lines, it would start with
[okay]_0=No error.
[okay]_1=Comment.
[warning]_2=Warning.
[error]_3=Serious error.
[error]_4=Fatal error.

If all this looks intact on your system, try running bare Python without the IDE by changing to your Python directory under Statistics and running
import spss
to see whether it can do the import successfully.

On Thu, Apr 19, 2018 at 7:38 AM, David Marso <[hidden email]> wrote:
Jon sent me the following off list and  sort of got some things to work:
Actually reexamining the email t looks like the list was also addressed but
I don't see it here. ODD.  THANKS Jon.

"Not the SPSS installation directory.  It should be the
python/lib/site-packages directory under it.  Also, the sitecustomize.py
file should be in the site-packages directory of the Anaconda installation.
Spider might have some of its own logic, so put a print statement in the
file to prove that it was executed or check sys.path before invoking the
spss import."

This as driving me mad because somehow all of my folders became read only
;-((((
Fixed that (sort of).


Now It at least locates the spss path and tries to get up but then falls
down.

  File "C:\Program
Files\IBM\SPSS\Statistics\22\Python\Lib\site-packages\spss\errMsg.py", line
35, in __init__
    self.errMsg = errTable['okay'][str(0)]

KeyError: 'okay'

Probably something simple but the python ecosystem boggles me at the moment.

This is running in python 2.7.
 I would greatly prefer to learn python 3.x but I found there were even more
issues there. Details later after I sort this issue in 2.7



-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
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



--
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: How do I add SPSS to python sys.path?

David Marso
Administrator
Hi Jon,
Thanks!  The files are intact and the import works I'm able to get return
from
spss.Submit("ECHO 'gangs all here'.")
goes to python window as expected.
Maybe something is goofy with Spyder?
David
-----------

Jon Peck wrote

> There is some really ugly ten-year-old code in the Python code executed on
> the first import spss, but I have never seen this error before.  I don't
> have V22, but I don't think the later versions have changed.
>
> So, what I can tell without being able to reproduce this problem is that
> the initialization code is failing to set up the Python errTable
> dictionary, and, therefore, when it goes to issue an error message, it
> can't find its basic string which is, ironically, 'No error.'
>
> The startup code locates the SPSS Python error message file, which is
> expected to be (for English)
> C:\spss24\Python\Lib\site-packages\spss\lang\en\spsspy.properties
> in V24 so spss22 or wherever you have V22 installed in your case.
>
> If it doesn't find this file, it raises an exception with message [sic]
> Can not find error message file.
> and stops
>
> If it does find a file by that name, it reads it and initializes the
> errTable dictionary from it.  So, if you didn't get the above error
> message, it would mean that the spsspy.properties file is present but
> corrupted somehow.  Ignoring comment lines, it would start with
> [okay]_0=No error.
> [okay]_1=Comment.
> [warning]_2=Warning.
> [error]_3=Serious error.
> [error]_4=Fatal error.
>
> If all this looks intact on your system, try running bare Python without
> the IDE by changing to your Python directory under Statistics and running
> import spss
> to see whether it can do the import successfully.
>
> On Thu, Apr 19, 2018 at 7:38 AM, David Marso &lt;

> david.marso@

> &gt; wrote:
>
>> Jon sent me the following off list and  sort of got some things to work:
>> Actually reexamining the email t looks like the list was also addressed
>> but
>> I don't see it here. ODD.  THANKS Jon.
>>
>> "Not the SPSS installation directory.  It should be the
>> python/lib/site-packages directory under it.  Also, the sitecustomize.py
>> file should be in the site-packages directory of the Anaconda
>> installation.
>> Spider might have some of its own logic, so put a print statement in the
>> file to prove that it was executed or check sys.path before invoking the
>> spss import."
>>
>> This as driving me mad because somehow all of my folders became read only
>> ;-((((
>> Fixed that (sort of).
>>
>>
>> Now It at least locates the spss path and tries to get up but then falls
>> down.
>>
>>   File "C:\Program
>> Files\IBM\SPSS\Statistics\22\Python\Lib\site-packages\spss\errMsg.py",
>> line
>> 35, in __init__
>>     self.errMsg = errTable['okay'][str(0)]
>>
>> KeyError: 'okay'
>>
>> Probably something simple but the python ecosystem boggles me at the
>> moment.
>>
>> This is running in python 2.7.
>>  I would greatly prefer to learn python 3.x but I found there were even
>> more
>> issues there. Details later after I sort this issue in 2.7
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> ---
>> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
>> porcos
>> ne forte conculcent eas pedibus suis."
>> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff
>> in
>> abyssum?"
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

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

> jkpeck@

>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: How do I add SPSS to python sys.path?

Jon Peck
The Spyder environment may be doing something weird.  I use Wing  IDE for external debugging, and it works very well.  You might try creating a trivial Python program in a Spyder window
import spss
print spss

and then debugging it.  You would set a breakpoint in the spss\__init__.py file in the __SetErrorMessage function starting after the 
errLines = 
line
track/watch the errTable object or look at it after the return from __SetErrorMessage to see how it is populated.

On Thu, Apr 19, 2018 at 9:17 AM, David Marso <[hidden email]> wrote:
Hi Jon,
Thanks!  The files are intact and the import works I'm able to get return
from
spss.Submit("ECHO 'gangs all here'.")
goes to python window as expected.
Maybe something is goofy with Spyder?
David
-----------

Jon Peck wrote
> There is some really ugly ten-year-old code in the Python code executed on
> the first import spss, but I have never seen this error before.  I don't
> have V22, but I don't think the later versions have changed.
>
> So, what I can tell without being able to reproduce this problem is that
> the initialization code is failing to set up the Python errTable
> dictionary, and, therefore, when it goes to issue an error message, it
> can't find its basic string which is, ironically, 'No error.'
>
> The startup code locates the SPSS Python error message file, which is
> expected to be (for English)
> C:\spss24\Python\Lib\site-packages\spss\lang\en\spsspy.properties
> in V24 so spss22 or wherever you have V22 installed in your case.
>
> If it doesn't find this file, it raises an exception with message [sic]
> Can not find error message file.
> and stops
>
> If it does find a file by that name, it reads it and initializes the
> errTable dictionary from it.  So, if you didn't get the above error
> message, it would mean that the spsspy.properties file is present but
> corrupted somehow.  Ignoring comment lines, it would start with
> [okay]_0=No error.
> [okay]_1=Comment.
> [warning]_2=Warning.
> [error]_3=Serious error.
> [error]_4=Fatal error.
>
> If all this looks intact on your system, try running bare Python without
> the IDE by changing to your Python directory under Statistics and running
> import spss
> to see whether it can do the import successfully.
>
> On Thu, Apr 19, 2018 at 7:38 AM, David Marso &lt;

> david.marso@

> &gt; wrote:
>
>> Jon sent me the following off list and  sort of got some things to work:
>> Actually reexamining the email t looks like the list was also addressed
>> but
>> I don't see it here. ODD.  THANKS Jon.
>>
>> "Not the SPSS installation directory.  It should be the
>> python/lib/site-packages directory under it.  Also, the sitecustomize.py
>> file should be in the site-packages directory of the Anaconda
>> installation.
>> Spider might have some of its own logic, so put a print statement in the
>> file to prove that it was executed or check sys.path before invoking the
>> spss import."
>>
>> This as driving me mad because somehow all of my folders became read only
>> ;-((((
>> Fixed that (sort of).
>>
>>
>> Now It at least locates the spss path and tries to get up but then falls
>> down.
>>
>>   File "C:\Program
>> Files\IBM\SPSS\Statistics\22\Python\Lib\site-packages\spss\errMsg.py",
>> line
>> 35, in __init__
>>     self.errMsg = errTable['okay'][str(0)]
>>
>> KeyError: 'okay'
>>
>> Probably something simple but the python ecosystem boggles me at the
>> moment.
>>
>> This is running in python 2.7.
>>  I would greatly prefer to learn python 3.x but I found there were even
>> more
>> issues there. Details later after I sort this issue in 2.7
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> ---
>> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
>> porcos
>> ne forte conculcent eas pedibus suis."
>> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff
>> in
>> abyssum?"
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

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

> jkpeck@

>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
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



--
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: How do I add SPSS to python sys.path?

David Marso
Administrator
Hi Jon,

I did as suggested and it never hits the line in question.
Running from a prompt:

def __SetErrorMessage():
    """Read the error messages from spsspy.properties file,
    and initial global object 'errTable' with the error messages.
    """
    # read error messages from messages.err file
    language = __GetLanguage()    
    errfile = __findLocalizedErrfile(language)
   
   
    fp = open(errfile,"r")
    errLines = fp.readlines()
    print "__SetErrorMessage AFTER errLines = fp.readlines()"
    fp.close()

I get self.errMsg =errTable['okay'][str(0)]
Apparently the table is not being populated...




Jon Peck wrote

> The Spyder environment may be doing something weird.  I use Wing  IDE for
> external debugging, and it works very well.  You might try creating a
> trivial Python program in a Spyder window
> import spss
> print spss
>
> and then debugging it.  You would set a breakpoint in the spss\__init__.py
> file in the __SetErrorMessage function starting after the
> errLines =
> line
> track/watch the errTable object or look at it after the return from
> __SetErrorMessage to see how it is populated.
>
> On Thu, Apr 19, 2018 at 9:17 AM, David Marso &lt;

> david.marso@

> &gt; wrote:
>
>> Hi Jon,
>> Thanks!  The files are intact and the import works I'm able to get return
>> from
>> spss.Submit("ECHO 'gangs all here'.")
>> goes to python window as expected.
>> Maybe something is goofy with Spyder?
>> David
>> -----------
>>
>> Jon Peck wrote
>> > There is some really ugly ten-year-old code in the Python code executed
>> on
>> > the first import spss, but I have never seen this error before.  I
>> don't
>> > have V22, but I don't think the later versions have changed.
>> >
>> > So, what I can tell without being able to reproduce this problem is
>> that
>> > the initialization code is failing to set up the Python errTable
>> > dictionary, and, therefore, when it goes to issue an error message, it
>> > can't find its basic string which is, ironically, 'No error.'
>> >
>> > The startup code locates the SPSS Python error message file, which is
>> > expected to be (for English)
>> > C:\spss24\Python\Lib\site-packages\spss\lang\en\spsspy.properties
>> > in V24 so spss22 or wherever you have V22 installed in your case.
>> >
>> > If it doesn't find this file, it raises an exception with message [sic]
>> > Can not find error message file.
>> > and stops
>> >
>> > If it does find a file by that name, it reads it and initializes the
>> > errTable dictionary from it.  So, if you didn't get the above error
>> > message, it would mean that the spsspy.properties file is present but
>> > corrupted somehow.  Ignoring comment lines, it would start with
>> > [okay]_0=No error.
>> > [okay]_1=Comment.
>> > [warning]_2=Warning.
>> > [error]_3=Serious error.
>> > [error]_4=Fatal error.
>> >
>> > If all this looks intact on your system, try running bare Python
>> without
>> > the IDE by changing to your Python directory under Statistics and
>> running
>> > import spss
>> > to see whether it can do the import successfully.
>> >
>> > On Thu, Apr 19, 2018 at 7:38 AM, David Marso &lt;
>>
>> > david.marso@
>>
>> > &gt; wrote:
>> >
>> >> Jon sent me the following off list and  sort of got some things to
>> work:
>> >> Actually reexamining the email t looks like the list was also
>> addressed
>> >> but
>> >> I don't see it here. ODD.  THANKS Jon.
>> >>
>> >> "Not the SPSS installation directory.  It should be the
>> >> python/lib/site-packages directory under it.  Also, the
>> sitecustomize.py
>> >> file should be in the site-packages directory of the Anaconda
>> >> installation.
>> >> Spider might have some of its own logic, so put a print statement in
>> the
>> >> file to prove that it was executed or check sys.path before invoking
>> the
>> >> spss import."
>> >>
>> >> This as driving me mad because somehow all of my folders became read
>> only
>> >> ;-((((
>> >> Fixed that (sort of).
>> >>
>> >>
>> >> Now It at least locates the spss path and tries to get up but then
>> falls
>> >> down.
>> >>
>> >>   File "C:\Program
>> >> Files\IBM\SPSS\Statistics\22\Python\Lib\site-packages\spss\errMsg.py",
>> >> line
>> >> 35, in __init__
>> >>     self.errMsg = errTable['okay'][str(0)]
>> >>
>> >> KeyError: 'okay'
>> >>
>> >> Probably something simple but the python ecosystem boggles me at the
>> >> moment.
>> >>
>> >> This is running in python 2.7.
>> >>  I would greatly prefer to learn python 3.x but I found there were
>> even
>> >> more
>> >> issues there. Details later after I sort this issue in 2.7
>> >>
>> >>
>> >>
>> >> -----
>> >> Please reply to the list and not to my personal email.
>> >> Those desiring my consulting or training services please feel free to
>> >> email me.
>> >> ---
>> >> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
>> >> porcos
>> >> ne forte conculcent eas pedibus suis."
>> >> Cum es damnatorum possederunt porcos iens ut salire off sanguinum
>> cliff
>> >> in
>> >> abyssum?"
>> >> --
>> >> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>> >>
>> >> =====================
>> >> To manage your subscription to SPSSX-L, send a message to
>> >>
>>
>> > LISTSERV@.UGA
>>
>> >  (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
>>
>> > jkpeck@
>>
>> >
>> > =====================
>> > To manage your subscription to SPSSX-L, send a message to
>>
>> > LISTSERV@.UGA
>>
>> >  (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
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> ---
>> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
>> porcos
>> ne forte conculcent eas pedibus suis."
>> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff
>> in
>> abyssum?"
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

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

> jkpeck@

>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: How do I add SPSS to python sys.path?

Jon Peck
That makes me think your breakpoint is in the wrong version of the spss.py module.   What do see for sys.path?  Note that the path may depend on where you start Python from.

On Tue, Apr 24, 2018 at 12:56 AM, David Marso <[hidden email]> wrote:
Hi Jon,

I did as suggested and it never hits the line in question.
Running from a prompt:

def __SetErrorMessage():
    """Read the error messages from spsspy.properties file,
    and initial global object 'errTable' with the error messages.
    """
    # read error messages from messages.err file
    language = __GetLanguage()   
    errfile = __findLocalizedErrfile(language)


    fp = open(errfile,"r")
    errLines = fp.readlines()
    print "__SetErrorMessage AFTER errLines = fp.readlines()"
    fp.close()

I get self.errMsg =errTable['okay'][str(0)]
Apparently the table is not being populated...




Jon Peck wrote
> The Spyder environment may be doing something weird.  I use Wing  IDE for
> external debugging, and it works very well.  You might try creating a
> trivial Python program in a Spyder window
> import spss
> print spss
>
> and then debugging it.  You would set a breakpoint in the spss\__init__.py
> file in the __SetErrorMessage function starting after the
> errLines =
> line
> track/watch the errTable object or look at it after the return from
> __SetErrorMessage to see how it is populated.
>
> On Thu, Apr 19, 2018 at 9:17 AM, David Marso &lt;

> david.marso@

> &gt; wrote:
>
>> Hi Jon,
>> Thanks!  The files are intact and the import works I'm able to get return
>> from
>> spss.Submit("ECHO 'gangs all here'.")
>> goes to python window as expected.
>> Maybe something is goofy with Spyder?
>> David
>> -----------
>>
>> Jon Peck wrote
>> > There is some really ugly ten-year-old code in the Python code executed
>> on
>> > the first import spss, but I have never seen this error before.  I
>> don't
>> > have V22, but I don't think the later versions have changed.
>> >
>> > So, what I can tell without being able to reproduce this problem is
>> that
>> > the initialization code is failing to set up the Python errTable
>> > dictionary, and, therefore, when it goes to issue an error message, it
>> > can't find its basic string which is, ironically, 'No error.'
>> >
>> > The startup code locates the SPSS Python error message file, which is
>> > expected to be (for English)
>> > C:\spss24\Python\Lib\site-packages\spss\lang\en\spsspy.properties
>> > in V24 so spss22 or wherever you have V22 installed in your case.
>> >
>> > If it doesn't find this file, it raises an exception with message [sic]
>> > Can not find error message file.
>> > and stops
>> >
>> > If it does find a file by that name, it reads it and initializes the
>> > errTable dictionary from it.  So, if you didn't get the above error
>> > message, it would mean that the spsspy.properties file is present but
>> > corrupted somehow.  Ignoring comment lines, it would start with
>> > [okay]_0=No error.
>> > [okay]_1=Comment.
>> > [warning]_2=Warning.
>> > [error]_3=Serious error.
>> > [error]_4=Fatal error.
>> >
>> > If all this looks intact on your system, try running bare Python
>> without
>> > the IDE by changing to your Python directory under Statistics and
>> running
>> > import spss
>> > to see whether it can do the import successfully.
>> >
>> > On Thu, Apr 19, 2018 at 7:38 AM, David Marso &lt;
>>
>> > david.marso@
>>
>> > &gt; wrote:
>> >
>> >> Jon sent me the following off list and  sort of got some things to
>> work:
>> >> Actually reexamining the email t looks like the list was also
>> addressed
>> >> but
>> >> I don't see it here. ODD.  THANKS Jon.
>> >>
>> >> "Not the SPSS installation directory.  It should be the
>> >> python/lib/site-packages directory under it.  Also, the
>> sitecustomize.py
>> >> file should be in the site-packages directory of the Anaconda
>> >> installation.
>> >> Spider might have some of its own logic, so put a print statement in
>> the
>> >> file to prove that it was executed or check sys.path before invoking
>> the
>> >> spss import."
>> >>
>> >> This as driving me mad because somehow all of my folders became read
>> only
>> >> ;-((((
>> >> Fixed that (sort of).
>> >>
>> >>
>> >> Now It at least locates the spss path and tries to get up but then
>> falls
>> >> down.
>> >>
>> >>   File "C:\Program
>> >> Files\IBM\SPSS\Statistics\22\Python\Lib\site-packages\spss\errMsg.py",
>> >> line
>> >> 35, in __init__
>> >>     self.errMsg = errTable['okay'][str(0)]
>> >>
>> >> KeyError: 'okay'
>> >>
>> >> Probably something simple but the python ecosystem boggles me at the
>> >> moment.
>> >>
>> >> This is running in python 2.7.
>> >>  I would greatly prefer to learn python 3.x but I found there were
>> even
>> >> more
>> >> issues there. Details later after I sort this issue in 2.7
>> >>
>> >>
>> >>
>> >> -----
>> >> Please reply to the list and not to my personal email.
>> >> Those desiring my consulting or training services please feel free to
>> >> email me.
>> >> ---
>> >> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
>> >> porcos
>> >> ne forte conculcent eas pedibus suis."
>> >> Cum es damnatorum possederunt porcos iens ut salire off sanguinum
>> cliff
>> >> in
>> >> abyssum?"
>> >> --
>> >> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>> >>
>> >> =====================
>> >> To manage your subscription to SPSSX-L, send a message to
>> >>
>>
>> > LISTSERV@.UGA
>>
>> >  (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
>>
>> > jkpeck@
>>
>> >
>> > =====================
>> > To manage your subscription to SPSSX-L, send a message to
>>
>> > LISTSERV@.UGA
>>
>> >  (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
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> ---
>> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
>> porcos
>> ne forte conculcent eas pedibus suis."
>> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff
>> in
>> abyssum?"
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

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

> jkpeck@

>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
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



--
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: How do I add SPSS to python sys.path?

David Marso
Administrator
If I execute from the python directory of SPSS I get the expected result.
I had to download Anaconda3 again this AM because Spyder got FUBAR -couldn't
even resolve runfile-
Will reinstall and do a bit more tinkering.  
Question: Will python 3.6 be a problem with interacting with spss ver 22?
I figure if I am to jump into python, might as well be a current version?




-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: How do I add SPSS to python sys.path?

Jon Peck
No, you can't use Python 3.6 with SPSS 22.  You need to stick with 2.7.  With V25, you can use 3.4 via begin program python3.

On Tue, Apr 24, 2018 at 12:21 PM, David Marso <[hidden email]> wrote:
If I execute from the python directory of SPSS I get the expected result.
I had to download Anaconda3 again this AM because Spyder got FUBAR -couldn't
even resolve runfile-
Will reinstall and do a bit more tinkering. 
Question: Will python 3.6 be a problem with interacting with spss ver 22?
I figure if I am to jump into python, might as well be a current version?




-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
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



--
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: How do I add SPSS to python sys.path?

Andy W
In reply to this post by David Marso
I have no idea how to fix your specific problems, but I have personally never
been able to get Spyder to work on any machine I have ever had (all Windows
OS), whether or not I have admin privileges. (Even if I can go and make sure
the install works from the command line.)

Downloading the Anaconda distribution I have few to no problems though with
Jupyter notebooks (although I don't like the notebooks very much), and to
install packages I use conda from the command line. I currently use Rodeo as
an IDE, https://rodeo.yhat.com/, which you can set what home directory of
python you want to use. Again no problems with that, even when I cannot get
Spyder to work.

That is again all on Windows machines, but is for Python V2.whatever. [Have
not made the leap to 3.]



-----
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/