简体   繁体   中英

Terminal says “PyObjCTools” doesn't exist when it does

I am attempting to build a Python application on OSX 10.10, I have used MacPorts to install all dependencies and have used PyCharm to write the application. When I run it from PyCharm everything works fine, but when I try to run the build script, when it comes to the py2app part it tells me that the directory ".../PyObjC/PyObjCTools" isn't there, but I can navigate to it in Finder and it's very clearly there. Does anyone have any idea what my problem could be? I've been running around in circles with this for a week now.

If it's access to the PyObjCTools functionality you want, you should import it the Python way, for example:

from PyObjCTools import AppHelper

If you need to access actual files, it's possible to force py2app to add files using the setup data_files options. For example:

from setuptools import setup

setup(
app=['main.py'],
name="App Name",
data_files=['/path/to/folder'],
setup_requires=['py2app'],
options=dict(py2app=dict(iconfile='en.lproj/icon.icns',
                         includes=['includename'],
                         packages=['packagename']
                         )   
             )   
)

After a rebuild the files are located inside the Cocoa bundle Resources folder, which you can find using the resourcePath() function:

NSBundle.mainBundle().resourcePath()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM