I installed the iphone-python package from Cydia, but the HelloPython app closes immediately when I run it from Springboard.
This may be a red herring, but I found the .py file in Terminal and tried to run it with python and got a python error:
$ python /private/var/stash/Applications.pwn/HelloPython.app/HelloPython.py
Traceback (most recent call last):
File "/private/var/stash/Applications.pwn/HelloPython.app/HelloPython.py", line 9, in <module>
import objc
File "/usr/lib/python2.5/objc/__init__.py", line 17, in <module>
_update()
File "/usr/lib/python2.5/objc/__init__.py", line 14, in _update
import _objc
ImportError: dlopen(/usr/lib/python2.5/lib-dynload/_objc.dylib, 2): Symbol not found: _OBJC_CLASS_$_Object
Referenced from: /usr/lib/python2.5/lib-dynload/_objc.dylib
Expected in: /usr/lib/libobjc.A.dylib
I'm running 4.3.3.
How can I get this app working, so I'll have a working example of PyObjC?
Well due to the changes in the way executables on the new ios run, the dynamic library has become corrupt. The mach-o will no longer run due to the upgraded objective-c so a workaround would be to compile pyobjc from source and run normaly. The only ptoblem with that is that the iphone's version of pyobjc is built for uikit so you would need to find saurik's (Jay Freeman) source code and compile it. I might do that for myself so ill post back with a deb file if i do.
Related
Windows 10
Python 3.8
CUDA 11.5
I've installed what I believe to be a matching pycuda from this file:
pycuda-2021.1+cuda115-cp38-cp38-win_amd64.whl
This simple example fails
import pycuda.driver as drv
drv.init()
print("Detected {} CUDA devices".format(drv.Device.count()))
With this error:
Traceback (most recent call last):
File "C:/University of Arizona/weeds/tests/cuda-summary.py", line 5, in <module>
import pycuda.driver as drv
File "C:\Users\evan\AppData\Local\Programs\Python\Python38\lib\site-packages\pycuda\driver.py", line 65, in <module>
from pycuda._driver import * # noqa
ImportError: DLL load failed while importing _driver: The specified procedure could not be found.
NVCC is in my path
Adding os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], 'bin')) has no effect
The script works just fine on my Jetson Nano
Any ideas on how to get past this? I've searched and tried several solutions.
It is quite strange, but updating the Nvidia display driver fixed the issue for me.
But in my case there was no issue on my PC with the same versions of Windows, Python, CUDA and PyCuda. The issue appeared on the different Windows 10 machine, when launching the exe, packaged by PyInstaller. So, updating the display driver was the fix for this machine.
I'm getting an error whenever I try to start swift related to python. How do I fix this?
bash-3.2$ swift --version
Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1)
Target: x86_64-apple-darwin17.5.0
bash-3.2$ swift
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/Cellar/python#2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in
import weakref
File "/usr/local/Cellar/python#2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
I get the same error, because the swift REPL uses the python interpreter which homebrew installed at /usr/local/bin/python.
To avoid this you can
export PATH=/usr/bin:$PATH
swift
or
PATH=/usr/bin:$PATH swift
I'm sorry if my title doesn't make sense but that's the problem I'm having.
When executing a script at the command line, (or by double-clicking on it) using C:\pythonwin.exe SomeApp.pyw, I get a popup error box saying
ImportError: No module named wincon32. (Full error message at the bottom)
Just executing pythonwin.exe by itself with or without a script also has the same effect.
Google is amazingly bereft of any knowledge of wincon32. Trying to install wincon32 module with pip install wincon32 just says "Could not find a version that satisfies the requirement wincon32 (from version: ) No matching distribution found for wincon32"
pythonwin.exe is in the system's PATH.
Thanks for any help. Below is the full contents of the popup error box.
Title - Python Traceback
Traceback (most recent call last):
File "string", Line 1 in module
File "C:\Users\Me\Canopy(Python)\User\Lib\site-packages\pythonwin\pywin
\framework\startup.py", line 49, in _import_(moduleName)
File "C:\Users\Me\Canopy(Python)\User\Lib\site-packages\pythonwin\pywin
\framework\intpyapp.py", line 3, in import wincon32
ImportError: No module named wincon32
(I'm using Windows 10 x64)
Where did c:\Pythonwin.exe come from? It's not part of any Canopy installation that I've ever heard of. If you're trying to run Canopy Python, see https://support.enthought.com/entries/23646538-Make-Canopy-User-Python-be-your-default-Python
A similar question was asked before by someone else: https://stackoverflow.com/questions/23600028/py2app-app-crashes-on-earlier-mac-os-x-versions
I have an app that runs fine on my machine (OSX 10.9.4), but when I move it to another machine running 10.7.5, the app crashes on start up. I get the following messages in console:
Traceback (most recent call last):
File "/PATH_TO_APP/APP.app/Contents/Resources/__boot__.py", line 3
_recipes_pil_prescript(['Hdf5SubImagePlugin', 'FitsStubImagePlugin', 'SunImagePlugin', 'GbrImagePlugin', 'Jpeg2KImagePlugin', 'MicImagePlugin', 'FpxImagePlugin', ImImagePlugin', ...
File "/PATH_TO_APP/APP.app/Contents/Resources/__boot__.py, line 3
from PIL import Image
File "PIL/Image.pyc", line 62, in <module>
File "PIL/_imaging.pyc", line 14, in <module>
File "PIL/_imaging.pyc", line 10, in __load
ImportError: dlopen(/PATH_TO_APP/APP.app/Contents/Resources/lib/python2.7/lib-dynload/PIL/_imaging.so, 2): Symbol not found: ___sincos_stret
Referenced from /PATH_TO_APP/APP.app/Contents/Resources/lib/python2.7/lib-dynload/PIL/_imaging.so
Expected in: /usr/lib/libSystem.B.dylib
in /PATH_TO_APP/APP.app/Contents/Resources/lib/python2.7/lib-dynload/PIL/_imaging.so
Earlier, to get around this error, I just uninstalled pillow. I'm not sure why pillow libraries were being added to the app to begin with, since I didn't think I was using it. But now, when attempting this workaround, I get another error:
Traceback (most recent call last):
File "/PATH_TO_APP.app/APP.app/Contents/Resources/__boot__.py", line 384, in <module> _recipes_pil_prescript([])
File "/PATH_TO_APP.app/APP.app/Contents/Resources/__boot__.py", line 344, in _recipes_pil_prescript from PIL import Image
File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 62, in <module>
ImportError cannot import name _imaging
Apparently I'm using PIL now somehow. My script imports the following:
from __future__ import division
import easygui as eg
import os, zlib, re, datetime, getpass, tkMessageBox, sys
import zipfile as z
import Tkinter as tk
from tkFileDialog import askdirectory
from optparse import OptionParser
Here's my setup.py:
from setuptools import setup
APP = ['zipperscript.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True, 'excludes': ['']}
setup(
app=APP,
name="Zipperscript_HI_50",
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
version="Hawaii branch 4.0.50"
)
I'm not sure that the OS version is causing the problem, but that's my theory right now. I'm not sure how to proceed. Any help or suggestions are greatly appreciated.
I encountered a similar problem while using buildout on Mac OS 10.8.5. It seems that the pre-compiled packages available on Pypi have been compiled on newer versions of OS X and unfortunately insufficiently tested on older versions.
The solution is to install pillow from source instead. Download the source, and run pip install your_downloaded_file. You may need to install dependencies such as libjpeg and zlib beforehand.
After doing this I do not encounter the errors anymore and have pillow version 5.4.0 installed.
I am trying to add a Python script to into my project to obtain the build and marketing numbers directly from Git.
I have created a new target phase and that runs a script as explained in:
http://yeahrightkeller.com/2008/10/19/xcode-run-script-build-phase-tip/
And I have written a Python script that parses the program Info.plist using
from Foundation import NSMutableDictionary
However the script fails while being compiled and reports the following error to the build results:
Running a custom build phase script: gitversion.py
Traceback (most recent call last):
File "/Users/jorge/Documents/Programming iPod/Pruebas/RowOrder/Scripts/gitversion.py", line 9, in <module>
from Foundation import NSMutableDictionary
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/Foundation/__init__.py", line 8, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC/objc/__init__.py", line 26, in <module>
from _bridgesupport import *
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC/objc/_bridgesupport.py", line 9, in <module>
import pkg_resources
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 651, in <module>
class Environment(object):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 654, in Environment
def __init__(self, search_path=None, platform=get_supported_platform(), python=PY_MAJOR):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 55, in get_supported_platform
plat = get_build_platform(); m = macosVersionString.match(plat)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 181, in get_build_platform
plat = get_platform()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/util.py", line 97, in get_platform
cfgvars = get_config_vars()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py", line 525, in get_config_vars
func()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py", line 408, in _init_posix
raise DistutilsPlatformError(my_msg)
distutils.errors.DistutilsPlatformError: $MACOSX_DEPLOYMENT_TARGET mismatch: now "10.5" but "10.6" during configure
Finished running custom build phase script: gitversion.py (exit status = 1)
Clearly, distutils has somehow hardcoded that it is compiled for version 10.6 (Snow Leopard, that is the one I am using), but the project has the MacOSX Deployment target set to 10.5.
If i try to set this variable in the project to 10.6, I then get:
ld: library not found for -lcrt1.10.6.o
Any ideas on how to solve this issue? Thanks in advance.
I have the same problem, and I wanted to keep the python version because handling the plist via NSMutableDictionary is much nicer than using regex on Info.plist.
Building on Maxence's answer, the solution was to strip the python code out of the Run Script build phase into a gitversion.py file:
#!/usr/bin/env python
import os
from Foundation import NSMutableDictionary
from subprocess import Popen, PIPE
p = Popen(
"/sw/bin/git rev-parse --short HEAD",
stdout=PIPE,
close_fds=True,
shell=True)
version = p.stdout.read()
print version
info = os.environ['INFOPLIST_FILE']
print info
plist = NSMutableDictionary.dictionaryWithContentsOfFile_(info)
print plist
plist['revision'] = version[:-1]
plist.writeToFile_atomically_(info, 1)
Then replace the original Run Script with a shell script:
env MACOSX_DEPLOYMENT_TARGET=10.6 python gitversion.py
Be sure to remember to change the Shell setting to /bin/sh.
Apple distributes Python 2.5 and 2.6 with Snow Leopard (10.6) and both are built with a deployment target of 10.6. If you really do need to target your application for 10.5, you can't safely use the Apple-supplied Pythons on 10.6 to deploy on 10.5.
The easiest solution may be to download and install a Python 2.6 from python.org. That Python is targeted for 10.3+, so it will work on both 10.5 and 10.6. You'll probably also need to ensure that that Python is installed on all machines where your app will be deployed.
Another option might be to create a separate stand-alone helper app using py2app with the python.org 2.6 and deploy that along with your main app. Or create your whole app under py2app. In either case, the app would contain its own python framework interpreter and framework, independent of the system version.
EDIT: Based on your comment, I'm not sure I understand your problem. Since you are running on 10.6, it's not clear to me (1) why you have the deployment target set to 10.5 and (2) if you need to have the deployment set to 10.5. I'm going to guess that you had an existing Xcode project that was developed on 10.5 and then imported or upgraded from Xcode on 10.5 to Xcode on 10.6. If that is the case, then I think the only thing that should have been needed to be done is to change the Active SDK from 10.5 to 10.6 (in the overview) in the top of the project window. Doing just that and forcing a Clean All Targets should solve the crt library not found error; if not, there is something wrong with the project dependencies.
On the other hand, if you really do need to develop on 10.6 for 10.5, then it seems that your gitversion.py is introducing an inadvertent dependency on python 2.6 (as can be seen by the traceback), which is not part of 10.5. Unless you really need python 2.6 features, you should be able to eliminate that by using python 2.5 which Apple provides on both 10.5 and 10.6. In that case, perhaps all you need to do is to ensure that you invoke python in the build phase script with /usr/bin/python2.5 rather than just python.
For the purposes of this script, you can simply temporarily set the value of MACOSX_DEPLOYMENT_TARGET to 10.6. So your command would be:
env MACOSX_DEPLOYMENT_TARGET=10.6 gitversion.py
Here you can find ths SOLUTION:
http://marcocattai.posterous.com/xcode-project-version-number-using-gitsvn