Thank you, yes: using both the --with-python and --enable-framework flags
were necessary to resolve the Python library (albeit to the system Python
library, but perhaps that doesn't matter?).

otool output *without* --enable-framework:

    @rpath/Python (compatibility version 2.7.0, current version 2.7.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 1226.10.1)
    
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
(compatibility version 150.0.0, current version 1258.1.0)

​
otool output *with* --enable-framework:

    /System/Library/Frameworks/Python.framework/Versions/2.7/Python
(compatibility version 2.7.0, current version 2.7.10)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 1226.10.1)
    
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
(compatibility version 150.0.0, current version 1258.1.0)

​
Incidentally, otool shows the *@rpath/Python* line for the various Canopy
'Python' library files.

    @rpath/Python (compatibility version 2.7.0, current version 2.7.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 159.1.0)


Back to mod_wsgi-express, I found that using *install_name_tool* to add a
Canopy directory containing 'Python' prevents the 'image not found' error.
(Other errors crop up in the log file though, attached.)

install_name_tool -add_rpath $HOME/Library/Enthought/Canopy_64bit/User/ \
$HOME/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mod_wsgi-4.5.2-py2.7-macosx-10.6-x86_64.egg/mod_wsgi/server/mod_wsgi-py27.so

​

I'm happy to go without mod_wsgi-express, but if it's at all helpful to you
to get to the bottom of Canopy issues, I'm happy to try other things.

Thanks a lot for your help.

Stephen



On Thu, Apr 14, 2016 at 11:58 PM, Graham Dumpleton <
[email protected]> wrote:

> Rather than using the ‘pip’ installable mod_wsgi, you might want to try
> older way of building it from source code.
>
> Grab down latest source tar ball from:
>
>     https://github.com/GrahamDumpleton/mod_wsgi/releases
>
> When unpacked, build it using:
>
>     ./configure —with-python=/some/path/to/canopy/bin/python
>     make
>
> Before trying to install it, run:
>
>     otool -L src/server/.libs/mod_wsgi.so
>
> If that doesn’t show the Python library resolving, try instead:
>
>     make distclean
>     ./configure
> —with-python=/some/path/to/canopy/bin/python --enable-framework
>     make
>
> Run otool again. Does that then show it as resolving?
>
> Graham
>
> On 14 Apr 2016, at 10:13 PM, SGaffney <[email protected]> wrote:
>
> Thank you for the very fast response—excuse my slowness, caused by not
> setting up email alerts properly.
>
> Starting with last question first, the Python library/executable files:
>
> 1. Python / 'libpython2.7.so'
> ======================
>
> *$ find /Applications/Canopy.app -name Python -print*
>
>    1. /Applications/Canopy.app/Contents/Python
>    2.
>    
> /Applications/Canopy.app/Contents/Resources/Python.app/Contents/MacOS/Python
>    3.
>    
> /Applications/Canopy.app/Contents/Resources/PythonNoDock.app/Contents/MacOS/Python
>    4.
>    
> /Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/Python
>    5.
>    
> /Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/Resources/Python.app/Contents/MacOS/Python
>    6.
>    
> /Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/Resources/PythonNoDock.app/Contents/MacOS/Python
>
> *items 1,4: Mach-O 64-bit dynamically linked shared library x86_64
> *items 2,3,5,6: Mach-O 64-bit executable x86_64
>
> Item 1 is the source file for the following symlinks:
>
>    -     ~/Library/Enthought//Canopy_64bit/User/Python
>    -     ~/Library/Enthought//Canopy_64bit/System/Python
>    -     ~/Library/Enthought//Canopy_64bit/User/lib/libpython2.7.dylib
>    -     ~/Library/Enthought//Canopy_64bit/System/lib/libpython2.7.dylib
>
>
> Item 1 otool output:
>     Mach header
>           magic cputype cpusubtype  caps    filetype ncmds sizeofcmds
>  flags
>     MH_MAGIC_64  X86_64        ALL  0x00       DYLIB    12       1656
> NOUNDEFS DYLDLINK TWOLEVEL NO_REEXPORTED_DYLIBS
>
> 4 additional 'Python' executables in ~
> --------------------------------------------------
>
>    -
>    
> ~/Library/Enthought//Canopy_64bit/User/Resources/Python.app/Contents/MacOS/Python
>    -
>    
> ~/Library/Enthought//Canopy_64bit/System/Resources/Python.app/Contents/MacOS/Python
>    -
>    
> ~/Library/Enthought//Canopy_64bit/User/Resources/PythonNoDock.app/Contents/MacOS/Python
>    -
>    
> ~/Library/Enthought//Canopy_64bit/System/Resources/PythonNoDock.app/Contents/MacOS/Python
>
> * all Mach-O 64-bit executable x86_64
>
>
> 2. SDKs
> =======
>
> My mac (OSX 10.11) has 3 SDKs installed after multiple OS X and XCode
> updates:
>
>    - /Developer/SDKs/MacOSX10.5.sdk/
>    - /Developer/SDKs/MacOSX10.6.sdk.hide/
>    -
>    
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/bin/apr-1-config
>
> Note the '.hide' appended to the 10.6 SDK. Compilation of mod_wsgi-express
> didn't work until I did that. 10.6 is only there in response to an earlier
> Canopy issue. I installed it in Mavericks after seeing this Canopy support
> post
> <https://support.enthought.com/hc/en-us/articles/204469410-OS-X-GCC-Clang-and-Cython-in-10-9-Mavericks>
> .
>
>
> 3. Canopy lib folders
> ================
>
> $ tree /Applications/Canopy.app/Contents/lib/
> /Applications/Canopy.app/Contents/lib/
> └── python2.7
>     ├── config
>     │   ├── Makefile
>     │   ├── Setup
>     │   ├── Setup.config
>     │   ├── Setup.local
>     │   ├── config.c
>     │   ├── config.c.in
>     │   ├── enthought.dat
>     │   ├── install-sh
>     │   ├── libpython2.7.a
>     │   ├── libpython2.7.dylib
>     │   ├── makesetup
>     │   └── python.o
>     ├── lib-dynload
>     │   └── fcntl.so
>     ├── os.py
>     └── site.py
>
>
> Other lib directories in Canopy default virtual environments.
>
>    - ~/Library/Enthought/Canopy_64bit//System/lib
>    - ~/Library/Enthought/Canopy_64bit//User/lib
>
>
> 4. httpd
> ======
>
> $ file /usr/sbin/httpd
> /usr/sbin/httpd: Mach-O 64-bit executable x86_64
>
>
> 5. mod-wsgi-py27.so
> =================
>
>    - path:
>    
> ~/Library/Enthought/Canopy_64bit/User//lib/python2.7/site-packages/mod_wsgi-4.5.1-py2.7-macosx-10.6-x86_64.egg/mod_wsgi/server/mod_wsgi-py27.so
>    - size: 241Kb
>    - file: Mach-O 64-bit bundle x86_64
>    - otool:
>
>       magic cputype cpusubtype  caps    filetype ncmds sizeofcmds
>  flags
> MH_MAGIC_64  X86_64        ALL  0x00      BUNDLE    13       1672
> NOUNDEFS DYLDLINK TWOLEVEL
>
>
> 6. *-config files
> ===========
>
> python2.7-config
> ----------------------
>
>    - /usr/bin/python2.7-config
>    -
>    
> /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
>    -
>    
> /Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/bin/python2.7-config
>    - ~/Library/Enthought/Canopy_64bit/System/bin/python2.7-config
>    - ~/Library/Enthought/Canopy_64bit/User/bin/python2.7-config
>
>
> apr-1-config
> ----------------
>
>    -
>    
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/bin/apr-1-config
>    - /Developer/SDKs/MacOSX10.5.sdk/usr/bin/apr-1-config
>    - /Developer/SDKs/MacOSX10.6.sdk.hide/usr/bin/apr-1-config
>    - /usr/bin/apr-1-config
>    - /usr/local/Library/ENV/4.3/apr-1-config
>
>
> Thanks for your time and for any further pointers,
>
> Stephen
>
>
>
> On Wednesday, April 13, 2016 at 11:43:32 AM UTC+1, Graham Dumpleton wrote:
>>
>> Actually this could just be it not even finding the Python framework. On
>> older MacOS X versions it wasn’t uncommon for third party Python
>> installations to screw things up so that it wasn’t actually possible to
>> link to their framework from a separate application.
>>
>> All the LD_RUN_PATH is not used on MacOS X. That is Linux or Solaris.
>>
>> I can’t remember how to you fix up the framework reference in mod_wsgi.so
>> if it is broken.
>>
>> I don’t think you can simply set the environment variable:
>>
>>
>>   
>> DYLD_LIBRARY_PATH=/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib
>>
>> when running mod_wsgi-express.
>>
>> That doesn’t seem to be the correct directory for where the framework
>> library might be installed anyway.
>>
>> What do you get for:
>>
>>     find /Applications/Canopy.app -name Python -print
>>
>> Graham
>>
>> On 13 Apr 2016, at 8:34 PM, Graham Dumpleton <[email protected]>
>> wrote:
>>
>> Are you really running MacOS X 10.6?
>>
>> This issue used to come up in old MacOS X versions.
>>
>> The problem is that one of Apache, mod_wsgi or the Python library doesn’t
>> have a binary image in it for the required architecture. That is, 32 bit or
>> 64 bit.
>>
>> What do you get when you run:
>>
>>     file mod_wsgi-py27.so
>>
>>     file /usr/sbin/httpd
>>
>>     file
>> /Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/
>> libpython2.7.so
>>
>> You may have to work out the correct path for each of these.
>>
>> There was some notes about related issue in really old documentation on
>> old Google Code site about things like this.
>>
>>
>> https://code.google.com/archive/p/modwsgi/wikis/InstallationOnMacOSX.wiki
>>
>> Graham
>>
>> On 13 Apr 2016, at 8:25 PM, SGaffney <[email protected]> wrote:
>>
>> Hello,
>>
>> I'm struggling with installation of mod_wsgi-express in my Canopy
>> distribution. Compilation works fine (output from python setup.py install
>> is attached), but when I run `mod_wsgi-express start-server`, I get the
>> error "Library not loaded: @rpath/Python" (follows email).
>>
>> From related support posts, I see that setting the LD_RUN_PATH at
>> compilation is crucial, but the setup.py file seems to get mine right:
>> *[from debugger inspection in setup.py before "# Now finally run
>> distutils."]*
>> >> *LD_RUN_PATH*
>>
>> '/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib:/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/config'
>> >> *PYTHON_LDFLAGS*
>> ['-L/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib',
>> '-L/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/config']
>> >> *PYTHON_LDLIBS*
>> ['-lpython2.7']
>>
>> And here's the output of ldd on the .so file:
>> > ldd mod_wsgi-py27.so
>> @rpath/Python (compatibility version 2.7.0, current version 2.7.0)
>> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
>> 1226.10.1)
>>
>> I'd be very grateful for any suggestions.
>>
>> Thank you,
>>
>> Stephen
>>
>> -------
>>
>> $ mod_wsgi-express start-server
>> Server URL         : http://localhost:8000/
>> Server Root        : /tmp/mod_wsgi-localhost:8000:502
>> Server Conf        : /tmp/mod_wsgi-localhost:8000:502/httpd.conf
>> Error Log File     : /tmp/mod_wsgi-localhost:8000:502/error_log (warn)
>> Request Capacity   : 5 (1 process * 5 threads)
>> Request Timeout    : 60 (seconds)
>> Queue Backlog      : 100 (connections)
>> Queue Timeout      : 45 (seconds)
>> Server Capacity    : 20 (event/worker), 20 (prefork)
>> Server Backlog     : 500 (connections)
>> Locale Setting     : en_GB.UTF-8
>> httpd (mod_wsgi-express) : Syntax error on line 151 of
>> /tmp/mod_wsgi-localhost:8000:502/httpd.conf: Cannot load
>> /Users/sgg/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mod_wsgi-4.5.1-py2.7-macosx-10.6-x86_64.egg/mod_wsgi/server/mod_wsgi-py27.so
>> into server:
>> dlopen(/Users/sgg/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mod_wsgi-4.5.1-py2.7-macosx-10.6-x86_64.egg/mod_wsgi/server/mod_wsgi-py27.so,
>> 10): *Library not loaded: @rpath/Python*\n  Referenced from:
>> /Users/sgg/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mod_wsgi-4.5.1-py2.7-macosx-10.6-x86_64.egg/mod_wsgi/server/mod_wsgi-py27.so\n
>>  Reason: image not found
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "modwsgi" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/modwsgi.
>> For more options, visit https://groups.google.com/d/optout.
>> <setup.py_install_output.txt>
>>
>>
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/modwsgi.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "modwsgi" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/modwsgi/liw8DqjK1XA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/modwsgi.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.
[mpm_prefork:notice] [pid 24237] AH00163: Apache/2.4.18 (Unix) mod_wsgi/4.5.2 
Python/2.7.10 configured -- resuming normal operations
[core:notice] [pid 24237] AH00094: Command line: 'httpd (mod_wsgi-express)  -f 
/tmp/mod_wsgi-localhost:8000:502/httpd.conf -D FOREGROUND'
[wsgi:error] [pid 24239] mod_wsgi (pid=24239): Target WSGI script 
'/tmp/mod_wsgi-localhost:8000:502/handler.wsgi' cannot be loaded as Python 
module.
[wsgi:error] [pid 24239] mod_wsgi (pid=24239): Exception occurred processing 
WSGI script '/tmp/mod_wsgi-localhost:8000:502/handler.wsgi'.
[wsgi:error] [pid 24239] Traceback (most recent call last):
[wsgi:error] [pid 24239]   File 
"/tmp/mod_wsgi-localhost:8000:502/handler.wsgi", line 7, in <module>
[wsgi:error] [pid 24239]     import mod_wsgi.server
[wsgi:error] [pid 24239] ImportError: No module named server
[wsgi:error] [pid 24239] [remote ::1:0] mod_wsgi (pid=24239): Target WSGI 
script '/tmp/mod_wsgi-localhost:8000:502/handler.wsgi' cannot be loaded as 
Python module.
[wsgi:error] [pid 24239] [remote ::1:0] mod_wsgi (pid=24239): Exception 
occurred processing WSGI script '/tmp/mod_wsgi-localhost:8000:502/handler.wsgi'.
[wsgi:error] [pid 24239] [remote ::1:0] Traceback (most recent call last):
[wsgi:error] [pid 24239] [remote ::1:0]   File 
"/tmp/mod_wsgi-localhost:8000:502/handler.wsgi", line 7, in <module>
[wsgi:error] [pid 24239] [remote ::1:0]     import mod_wsgi.server
[wsgi:error] [pid 24239] [remote ::1:0] ImportError: No module named server
[wsgi:error] [pid 24239] [remote ::1:0] mod_wsgi (pid=24239): Target WSGI 
script '/tmp/mod_wsgi-localhost:8000:502/handler.wsgi' cannot be loaded as 
Python module.
[wsgi:error] [pid 24239] [remote ::1:0] mod_wsgi (pid=24239): Exception 
occurred processing WSGI script '/tmp/mod_wsgi-localhost:8000:502/handler.wsgi'.
[wsgi:error] [pid 24239] [remote ::1:0] Traceback (most recent call last):
[wsgi:error] [pid 24239] [remote ::1:0]   File 
"/tmp/mod_wsgi-localhost:8000:502/handler.wsgi", line 7, in <module>
[wsgi:error] [pid 24239] [remote ::1:0]     import mod_wsgi.server
[wsgi:error] [pid 24239] [remote ::1:0] ImportError: No module named server
[mpm_prefork:notice] [pid 24237] AH00170: caught SIGWINCH, shutting down 
gracefully
[mpm_prefork:notice] [pid 24288] AH00163: Apache/2.4.18 (Unix) mod_wsgi/4.5.2 
Python/2.7.10 configured -- resuming normal operations
[core:notice] [pid 24288] AH00094: Command line: 'httpd (mod_wsgi-express)  -f 
/tmp/mod_wsgi-localhost:8000:502/httpd.conf -D FOREGROUND'
[wsgi:error] [pid 24290] mod_wsgi (pid=24290): Target WSGI script 
'/tmp/mod_wsgi-localhost:8000:502/handler.wsgi' cannot be loaded as Python 
module.
[wsgi:error] [pid 24290] mod_wsgi (pid=24290): Exception occurred processing 
WSGI script '/tmp/mod_wsgi-localhost:8000:502/handler.wsgi'.
[wsgi:error] [pid 24290] Traceback (most recent call last):
[wsgi:error] [pid 24290]   File 
"/tmp/mod_wsgi-localhost:8000:502/handler.wsgi", line 7, in <module>
[wsgi:error] [pid 24290]     import mod_wsgi.server
[wsgi:error] [pid 24290] ImportError: No module named server
[mpm_prefork:notice] [pid 24288] AH00170: caught SIGWINCH, shutting down 
gracefully

Reply via email to