path/can't find modules confusion wx 2.8 and 2.9

[WinXP, Python 2.5 & wx2.8.10...OR...Python 2.7 & wx2.9.4]

I had everything working fine in a setup using wxPython 2.8.10 or
2.9.4...and at some point borked it...and now I can't get it to play
nice...

I want to be able to run wxPython 2.8.10 as well as 2.9.4, and can,
but am having a problem importing 3rd party modules while running
2.9.4.

When I try to run a program (through Boa Constructor) in 2.8.10, all is well.

When I try to run the same program (through Boa Constructor) in 2.9.4,
I can run wxPython programs because of this code in my programs:

import sys
py_version = sys.version_info[:2]
if py_version == (2, 7):
    import wxversion
    wxversion.select('2.9')

But, and here is the problem, it can't find other 3rd party modules,
such as dateutil or win32api. I guess this makes sense, because the
list of paths in the two versions are different, and the 2.9 instance
doesn't have the Python25/Lib/site-packages directory listed, and
that's where all those modules were installed to long ago..

To fix that (at least as a test of that principle as it is a
suboptimal fix at best), I tried appending all the folders in the 2.8
path to sys.path list in the 2.9 instance, but then it said it
couldn't use the Python25.dll.

I *did* have this all working fine, but I don't recall how (why oh why
don't I keep a paper notebook of these secret recipes?). What's the
simplest/best way to have this work?

Che

C M wrote:

[WinXP, Python 2.5& wx2.8.10...OR...Python 2.7& wx2.9.4]

But, and here is the problem, it can't find other 3rd party modules,
such as dateutil or win32api. I guess this makes sense, because the
list of paths in the two versions are different, and the 2.9 instance
doesn't have the Python25/Lib/site-packages directory listed, and
that's where all those modules were installed to long ago..

To fix that (at least as a test of that principle as it is a
suboptimal fix at best), I tried appending all the folders in the 2.8
path to sys.path list in the 2.9 instance, but then it said it
couldn't use the Python25.dll.

I *did* have this all working fine, but I don't recall how (why oh why
don't I keep a paper notebook of these secret recipes?). What's the
simplest/best way to have this work?

You should install all the packages in both Pythons. If the package contains binary extension modules then you will need to install Python 2.7 specific versions of those files as Python 2.5 and Python 2.7 are not fully binary compatible.

···

--
Robin Dunn
Software Craftsman

Thanks, but is there any other way to do it? I thought I didn't have
to do that when I had this working a few months ago before I (somehow)
deleted Boa and back then everything just ran fine on both.

···

On Wed, Jul 17, 2013 at 10:59 PM, Robin Dunn <robin@alldunn.com> wrote:

C M wrote:

[WinXP, Python 2.5& wx2.8.10...OR...Python 2.7& wx2.9.4]

But, and here is the problem, it can't find other 3rd party modules,
such as dateutil or win32api. I guess this makes sense, because the
list of paths in the two versions are different, and the 2.9 instance
doesn't have the Python25/Lib/site-packages directory listed, and
that's where all those modules were installed to long ago..

To fix that (at least as a test of that principle as it is a
suboptimal fix at best), I tried appending all the folders in the 2.8
path to sys.path list in the 2.9 instance, but then it said it
couldn't use the Python25.dll.

I *did* have this all working fine, but I don't recall how (why oh why
don't I keep a paper notebook of these secret recipes?). What's the
simplest/best way to have this work?

You should install all the packages in both Pythons. If the package
contains binary extension modules then you will need to install Python 2.7
specific versions of those files as Python 2.5 and Python 2.7 are not fully
binary compatible.

C M wrote:

···

On Wed, Jul 17, 2013 at 10:59 PM, Robin Dunn<robin@alldunn.com> wrote:

C M wrote:

[WinXP, Python 2.5& wx2.8.10...OR...Python 2.7& wx2.9.4]

But, and here is the problem, it can't find other 3rd party modules,
such as dateutil or win32api. I guess this makes sense, because the
list of paths in the two versions are different, and the 2.9 instance
doesn't have the Python25/Lib/site-packages directory listed, and
that's where all those modules were installed to long ago..

To fix that (at least as a test of that principle as it is a
suboptimal fix at best), I tried appending all the folders in the 2.8
path to sys.path list in the 2.9 instance, but then it said it
couldn't use the Python25.dll.

I *did* have this all working fine, but I don't recall how (why oh why
don't I keep a paper notebook of these secret recipes?). What's the
simplest/best way to have this work?

You should install all the packages in both Pythons. If the package
contains binary extension modules then you will need to install Python 2.7
specific versions of those files as Python 2.5 and Python 2.7 are not fully
binary compatible.

Thanks, but is there any other way to do it? I thought I didn't have
to do that when I had this working a few months ago before I (somehow)
deleted Boa and back then everything just ran fine on both.

You could install pure python packages into a folder that is added to the PYTHONPATH or the sys.path of both Pythons, but anything with a binary extension module really must have python-specific versions installed. Depending on the platform and other factors some things may seem to work if you try to share extension modules between different versions of Python, but IMO you're just asking for trouble if you try it.

--
Robin Dunn
Software Craftsman

You could install pure python packages into a folder that is added to the
PYTHONPATH or the sys.path of both Pythons, but anything with a binary
extension module really must have python-specific versions installed.
Depending on the platform and other factors some things may seem to work if
you try to share extension modules between different versions of Python, but
IMO you're just asking for trouble if you try it.

OK, I've followed your advice and installed all the packages also for
Python 2.7, and that works, other than one issue...

I (re-)installed wxPython 2.9.4 for Python 2.7 and was testing out a
small wxPython script that I copied to
C:\\Python27\\lib\\site-packages. But when I run it, I get the error:

ImportError: No module named wx

But when I check the sys.path, 'C:\\Python27\\lib\\site-packages' is
included. I thought it would follow the subfolders and find wx?

If I put this code in (recommended by Gadget/Steve last year), and it
does find wx:

import sys
py_version = sys.version_info[:2]
print 'py version: ', py_version
if py_version == (2, 7):
    import wxversion
    wxversion.select('2.9')
import wx

Is there something I can set to not need to do this last block of code
each time?

Thanks,
Che

C M wrote:

You could install pure python packages into a folder that is added to the
PYTHONPATH or the sys.path of both Pythons, but anything with a binary
extension module really must have python-specific versions installed.
Depending on the platform and other factors some things may seem to work if
you try to share extension modules between different versions of Python, but
IMO you're just asking for trouble if you try it.

OK, I've followed your advice and installed all the packages also for
Python 2.7, and that works, other than one issue...

I (re-)installed wxPython 2.9.4 for Python 2.7 and was testing out a
small wxPython script that I copied to
C:\\Python27\\lib\\site-packages. But when I run it, I get the error:

ImportError: No module named wx

But when I check the sys.path, 'C:\\Python27\\lib\\site-packages' is
included. I thought it would follow the subfolders and find wx?

If I put this code in (recommended by Gadget/Steve last year), and it
does find wx:

import sys
py_version = sys.version_info[:2]
print 'py version: ', py_version
if py_version == (2, 7):
     import wxversion
     wxversion.select('2.9')
import wx

Is there something I can set to not need to do this last block of code
each time?

Normally there is a wx.pth file installed in site-packages that contains the name of the subfolder containing the wx package that should be added to the sys.path. However there is an option in the installer controlling whether that file will be installed or not. If you don't have one, or if you do and it contains the wrong value, then it is easy to fix. Just add your own .pth file that contains a relative path name to a folder you want added to the sys.path, such as "wx-2.9.4-msw"

···

--
Robin Dunn
Software Craftsman

Hi Che,

...

If I put this code in (recommended by Gadget/Steve last year), and it
does find wx:

import sys
py_version = sys.version_info[:2]
print 'py version: ', py_version
if py_version == (2, 7):
     import wxversion
     wxversion.select('2.9')
import wx

Is there something I can set to not need to do this last block of code
each time?

You should have a 'wx.pth' file in site-packages which points to the version you want to use, e.g.:

"wx-2.9.5-msw"

See you
Werner

···

On 19/07/2013 22:44, C M wrote:

Normally there is a wx.pth file installed in site-packages that contains the
name of the subfolder containing the wx package that should be added to the
sys.path. However there is an option in the installer controlling whether
that file will be installed or not. If you don't have one, or if you do and
it contains the wrong value, then it is easy to fix. Just add your own .pth
file that contains a relative path name to a folder you want added to the
sys.path, such as "wx-2.9.4-msw"

For some reason that wasn't there. That did the trick. Thanks again!

Yes, for some reason it wasn't in the 2.7 site-packages, but I copied
it from the 2.5 one and edited Thanks!

···

On Fri, Jul 19, 2013 at 5:04 PM, werner <wbruhin@free.fr> wrote:

Hi Che,

On 19/07/2013 22:44, C M wrote:

...

If I put this code in (recommended by Gadget/Steve last year), and it
does find wx:

import sys
py_version = sys.version_info[:2]
print 'py version: ', py_version
if py_version == (2, 7):
     import wxversion
     wxversion.select('2.9')
import wx

Is there something I can set to not need to do this last block of code
each time?

You should have a 'wx.pth' file in site-packages which points to the version
you want to use, e.g.:

"wx-2.9.5-msw"

See you
Werner