py2app crashes with PIL errors on earlier versions of OS X - osx-lion

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.

Related

PyCUDA -- problems importing pycuda.driver

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.

pySerial installed, but still getting ImportError

I am new to Python, so I have likely done something obviously wrong, though despite my best efforts I cannot figure out what.
I am running windows 7 64bit.
I only have Python 3.5 (32 bit) installed.
I updated pip to the latest version succesfully and used it to install pySerial. I am working in eclipse oxygen with PyDev installed. My run configuration does show the appropriate path (as far as I can tell):
run configuration in eclipse/PyDev
I have confirmed pySerial is installed by doing the following in python interpreter:
>>>help()
>>>modules
serial shows up in the list of modules.
also:
>>> import serial; print(serial.__file__)
C:\Python35\lib\site-packages\serial\__init__.py
Additionally, trying to use serial in the terminal works fine, as below:
>>> import serial
>>> s=serial.Serial("COM4")
>>> s
Serial<id=0x383b750, open=True>(port='COM4', baudrate=9600, bytesize=8, parity='N', stop
bits=1, timeout=None, xonxoff=False, rtscts=False, dsrdtr=False)
However, when I try to run the following code as a file:
import serial
print ("Test Script")
I get the following error:
Traceback (most recent call last):
File "C:\Users\H260643\Desktop\Projects\EclipseWorkspace\CMP_Thous_Hr\Base.py", line 1, in <module>
import serial
ImportError: No module named 'serial'
For what it's worth, the eclispe editor window has also flagged that line saying it is an "unresolved import: serial"
Right after posting this I realized that the install path for python/pySerial did not match what was in my eclispe/PyDev run configuration. I corrected my run configuration and all is well.

Vpython not working after update

I'm using ubuntu 16.04 and python files that were using vpython that were working fine before now crash showing
from visual import *
ImportError: No module named visual.
I installed anaconda, still nothing. I launched jupyter notebook on the terminal, it opens on a new window in google chrome. I created a test.py file containing just
import vpython
and it prompts:
Traceback (most recent call last):
File "teste vpython.py", line 1, in <module>
import vpython
File "/home/user/anaconda2/lib/python2.7/site-
packages/vpython/__init__.py", line 10, in <module>
from .vpython import *
File "/home/user/anaconda2/lib/python2.7/site-
packages/vpython/vpython.py", line 507, in <module>
get_ipython().kernel.comm_manager.register_target('glow', GlowWidget)
AttributeError: 'NoneType' object has no attribute 'kernel'
I would appreciate if somebody could help me. I know there are similar tags, but I did as every answer I checked as suggested with no results.
Thank you.
I have Ubuntu 16.04 with Anaconda and Python 3.6. Just now I created another environment that contains Python 2.7. In that environment I did "pip install vpython --upgrade" and verified with "pip show vpython" that the version is indeed 7.0.3. I then executed "jupyter notebook" and demo programs ran fine.
I am puzzled by your comment that you created a test.py file, and by the line that says "File "teste vpython.py", line 1, in ". I would expect a file with the .ipynb extension, so something doesn't seem right.
I'll advertise that a better place to pose VPython questions is in the VPython forum at
https://groups.google.com/forum/?fromgroups&hl=en#!forum/vpython-users

scipy not compiling on Python 3.4

When importing scipy:
from scipy import signal
I get the errors:
Traceback (most recent call last):
File "F:\Desktop\Programming\Python\Sample Programs\src\butter.py", line 7, in <module>
from scipy import signal
File "C:\Python34\lib\site-packages\scipy\signal\__init__.py", line 280, in <module>
from .bsplines import *
File "C:\Python34\lib\site-packages\scipy\signal\bsplines.py", line 12, in <module>
from scipy.special import comb, gamma
File "C:\Python34\lib\site-packages\scipy\special\__init__.py", line 601, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.`
I am running Eclipse on windows 7. I installed scipy successfully using
pip3.4 install "scipy-0.16.0rc1-cp34-none-win32.whl"
Can you tell me how I can get scipy to work with this simple program on Windows 7?
As mentioned prior, the easiest way to get SciPy running on windows is to simply download the Anaconda distribution. Be sure to obtain the version you want. It works out of the box. Plus you get Jupyter/IPython Notebook which is a really cool interactive GUI interface. It's almost like working in Matlab!
http://continuum.io/downloads

Python Hello World in PyObjC on iPhone?

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.