py2app throws [errno 35] Resource Not Available during unconditional imports
Asked Answered
M

2

1

I'm using python 2.7 installed via macports, pyobjc, cocoa and notably scipy (via FlowCytometryTools) with py2app to create a small mac application. Py2app's setup.py run with sudo python setup.py py2app completes nicely with -A for testing, but is unable to complete when running without that parameter to create a full .app build.

The build process will get a variable distance through the unconditional imports and then give error: [Errno 35] Resource temporarily unavailable and immediately exit. The number of unconditional import lines that complete before the error occurs changes. The longest run so far was seen when running immediately after a reboot. I've tried running with and without removing the previous build/dist folders to no effect.

Modules not found (unconditional imports):
...
 * builtins.int (Cython.Build.Inline, Cython.Compiler.ExprNodes, IPython.utils._tokenizeerror: [Errno 35] Resource temporarily unavailable

My setup.py looks like this:

import sys
sys.setrecursionlimit(1500) #required to avoid recursion triggered early exit in py2app while compiling scipy. (default is 1000)
from setuptools import setup

APP = ['FlowMac.py']
DATA_FILES = ['FlowMac_Main.xib']
OPTIONS = {'argv_emulation': True}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

and the imports section of my python file FlowMac.py looks like this:

from Cocoa import *
from Foundation import *
from AppKit import *
from FlowCytometryTools import * #file/data handling via scipy and pandas
from pylab import * #graphing histograms

Commenting out both the FlowCytometryTools and the pylab imports allows the py2app build to complete but of course renders the program nonfunctional.

  • What is happening?
  • How can I get more information on which resource is unavailable?
    • was hitting a recursion limit a clue to my problem?

I'm running Yosemite on a MacBook Pro with 8GB RAM, so I'm very surprised to be hitting a wall here. Thanks for your time.

UPDATE 4/29/2015: Importing everything works fine if I remove my .xib from the datafiles array of the py2app launcher setup.py. A blank file with just import Cocoa, Foundation and Appkit works fine. Importing the xib with any one of FlowCytometryTools, pylab, scipy, matplotlib, numpy does not work. pylab and FlowCytometryTools rely on the other three, and any one of scipy, matplotlib or numpy brings in py2app recipies for the other two. One of these recipies isn't working with the xib, but I don't know why...

Marking answered 1/1, 2015 at 1:3 Comment(0)
A
0

No experience with py2app, but I am wondering if you tried generating a more minimal version of the code that would fail to aid troubleshooting?

Maybe having FlowMac.py include nothing but the import statements:

import Cocoa
import Foundation
import AppKit
import FlowCytometryTools
import pylab

Also could you narrow it down to whether the problem appears due to pylab or due to FlowCytometryTools? (By commenting them out individually?)

Actor answered 12/1, 2015 at 4:20 Comment(5)
Hi Eugene! I did try disabling imports individually. The packager fails when I include import scipy either by itself or indirectly via FlowCytometryTools and/or pylab. Is there a way to get more information from the error? Not having a traceback or any other info about the error leaves py2app itself as a rather monolithic black box. The only other option I can think of would be to drop python all together and reimplement FlowCytometryTools in Objective-C to avoid py2app, but that would be pretty labor intensive.Marking
I assume this happens even if the FlowMac.py file contains nothing but "import scipy"? Again, I don't know py2app, but the recursion limit looks strange. A google search about that didn't seem to yield any results. Is it possible that something got messed up with the development environment? (Make you could try the build from a different machine?)Actor
I finally got access to another computer. The empty file with only "import scipy" works, but I get the same error with the full program. Going to have to do more semi-random digging to figure this out.Marking
Empty File with only "import FlowCytometryTools" also works. I'm mostly just stuck because I can't find information on the error, so there's no obvious way to debug it.Marking
Since the empty files with the imports work, I have some suspicion that the issue could be due to conflicts with namespaces. Try importing only the parts that the application requires; e.g., instead of using from FlowCytometryTools import * use from FlowCytometryTools import FCMeasurement, FCPlate etc. (doing so for all other imports.)Actor
N
0

From my testing, this error seems to be caused by the log output itself from py2app. Try redirecting standard error to a file:

python setup.py py2app 2>error_log

This should work around the error.

Nanananak answered 8/11, 2017 at 14:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.