RhetTbull / osxphotos

Python app to work with pictures and associated metadata from Apple Photos on macOS. Also includes a package to provide programmatic access to the Photos library, pictures, and metadata.
MIT License
2.17k stars 100 forks source link

Crashing on export with Darwin 13.2 #1007

Open spencerc99 opened 1 year ago

spencerc99 commented 1 year ago

Describe the bug Cannot export on Darwin 13.2

To Reproduce Steps to reproduce the behavior:

  1. What' the full command line you used with osxphotos? osxphotos export --download-missing --album fits\ ๐Ÿงข --use-photokit --skip-live --skip-original-if-edited --only-new --filename "{created.date}:{original_name}" --force-update --ignore-signature --convert-to-jpeg --post-function ./scripts/transform_exported_fits_into_db.py::post_function ./fits-export
  2. What was the error output? 94094 Abort trap:

Expected behavior should work

Screenshots

image

Desktop (please complete the following information):

RhetTbull commented 1 year ago

How did you install osxphotos? (e.g. pipx, pip, executable off the release page)

What version of python are you using? (python --version) and how did you install it? (e.g. via homebrew, python.org, etc.)

RhetTbull commented 1 year ago

Abort trap: 6 is an OS error. Other users are using osxphotos on 13.2 so I suspect this has to do with the python version. Assuming you installed this with pipx, I'd try the following:

If you've installed other apps with pipx, you'll want to do pipx reinstall-all

If the problem persists, I'll explore some more.

RhetTbull commented 1 year ago

I created a virtual machine with 13.2.1 tonight to try to replicate this but osxphotos ran fine. I tried both pipx and the pre-built binary and both worked.

spencerc99 commented 1 year ago

thanks for the help! i think it was something corrupted with my python installation (new machine). I'm now running into a weird issue with the post-function not being found? any ideas on this? I double-checked a lot of things and can't figure out what could be wrong

image
spencerc99 commented 1 year ago

oh wait i got around that problem and back to my normal issue hmm. let me do a full python reinstall and see

spencerc99 commented 1 year ago

perhaps something to do with this... https://stackoverflow.com/questions/24287239/abort-trap-6-when-running-a-python-script

spencerc99 commented 1 year ago
image

i just seem to get stuck as soon as it tries to export the first photo. I've tried without the post function and it still gets stuck

spencerc99 commented 1 year ago

i suspect it's partially related to me using conda to manage my python packages.. something weird with that and the newest mac os?

RhetTbull commented 1 year ago

i suspect it's partially related to me using conda to manage my python packages

I suspect so as well. I have tested osxphotos both with the homebrew version of python and the python.org version on 13.2 and they work as expected. I do not use Conda and have not tested it. (Early development with osxphotos was actually done via conda but I ran into issues...don't recall exactly what, and switched to python.org)

I suggest you install osxphotos via homebrew python + pipx and see if that works. That complicates your python setup because now you have multiple versions but that can be managed via path. For example, ensure conda path is first. pipx installs in ~/.local/bin so as long as that's in the path (pipx ensurepath) it should just work. I have a half-dozen python versions I use for testing (and manage paths via pyenv). If you do this, I'd uninstall osxphotos from the conda environment. If you need any additional packages for your post function, those can be installed with osxphotos install which will install packages into the same environment that osxphotos is installed in.

RhetTbull commented 1 year ago

@spencerc99 still having problems? Did you try with homebrew or pipx?

spencerc99 commented 1 year ago

thank you for checking in on me! I haven't had the time to really dive into this, but I'm still having issues. I am off of conda now and installed python via brew and running into this issue on running osxphotos now.

FileNotFoundError: [Errno 2] No such file or directory: '/opt/homebrew/lib/python3.11/site-packages/xattr/lib_build.h'

my series of commands were:

brew install python
python3 --version // Python 3.9.6
pip install osxphotos

It seems that osxphotos is in homebrew though?

which osxphotos // /opt/homebrew/bin/osxphotos
RhetTbull commented 1 year ago

Weird. I tried to recreate (though not exactly as my homebrew installed python 3.11). I had to specify exact paths to python as I use pyenv to manage global python and wanted to make sure I was using the homebrew version:

โฏ brew install python
...
โฏ /opt/homebrew/bin/python3 --version
Python 3.11.2
โฏ /opt/homebrew/bin/python3 -m pip install osxphotos
...
โฏ /opt/homebrew/bin/python3
Python 3.11.2 (main, Feb 16 2023, 02:55:59) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import osxphotos
>>> photosdb = osxphotos.PhotosDB()
>>> len(photosdb.photos())
34175
>>>
โฏ /opt/homebrew/bin/osxphotos export --limit 1 $TMPDIR
Using last opened Photos library: /Users/rhet/Pictures/Photos Library.photoslibrary
Exporting 35761 photos to /private/var/folders/wk/v6g10m256mb7l820g1cgpkm00000gn/T...
Exporting 35761 photos (limit = 1) โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 100% 0:00:00
Processed: 35761 photos, exported: 1, missing: 1, error: 0, limit: 1/1 exported
Elapsed time: 0:00:00

It seems that osxphotos is in homebrew though?

Yes, installing osxphotos with pip install osxphotos installs the CLI binary in the bin directory.

Looks like an issue with xattr package which is a dependency of osxphotos. Maybe try /opt/homebrew/bin/python3 -m pip install xattr and see if you still get the error?

I'm on Ventura 13.1 with Mac Mini M1 and osxphotos appears to be working fine with both the python.org python and the homebrew python.

oPromessa commented 1 year ago

Hey @RhetTbull.

Dumb question:

RhetTbull commented 1 year ago

@oPromessa Good catch!

@spencerc99 I think @oPromessa identified the issue: you're not running the python you think you are. Try which python3 and which pip. Do they refer to the homebrew install or the conda one you had previously (or something else?). I always run pip explicitly like this: python3 -m pip install ... because I've been bitten more than once by the pip in the path being different than the python in the path.

spencerc99 commented 1 year ago

okay so i've done a fresh install of python and have verified all the paths point to homebrew. I was still experiencing the original crash and abort error as before, and I seem to have narrowed it down to the --use-photokit option? (which is required for --download-missing). If I remove that option, everything works, but with that option on Ventura 13.2 and an M1 Mac seems to crash.

Is this a known issue or any advice @RhetTbull ?

breaking

image

vs.

image
spencerc99 commented 1 year ago

ย well.. maybe I spoke too soon. I got a different strange error without photokit..

image
oPromessa commented 1 year ago

Just to double check @spencerc99 on this new install what's the result of osxphotos --version to have origin, macOS and osxphotos' version info.

RhetTbull commented 1 year ago

@spencerc99 I'm on Ventura 13.1 / M1 Mac and I've confirmed --use-photokit works for me.

$ osxphotos --version
osxphotos, version 0.58.2
Python 3.11.2 (main, Feb 16 2023, 02:55:59) [Clang 14.0.0 (clang-1400.0.29.202)]
macOS 13.1.0, arm64

Try running your command with --debug placed directly after osxphotos export: osxphotos --debug export --album fits...

This should cause osxphotos to crash when it hits the error and produce a crash log. Then post the crash log file here.

spencerc99 commented 1 year ago

here's the latest version

image

and here's the latest crash run with the debug info (it does seem to be exporting now without --use-photokit btw)

image

I don't seem to see a crash log file, what should it look like?

oPromessa commented 1 year ago

Hi there.

Sorry for not having a solution. Just trying to help out.

RhetTbull commented 1 year ago

The crash log will only be created if there's a crash and it looks like it did not crash the second time. If it's really crashing in the photokit code then this code might not have been called the second time (only gets called to download missing photos) as perhaps all the photos were on disk and not missing this time.

I'm on Ventura / M1 and can't replicate this. Next time it happens, please insert the "--debug" option right after osxphotos and before export and see if you can get it to generate a crash log. Without that I can't figure out where in the code the error is occurring. Because Photos is flaky and errors are unfortunately expected during export, osxphotos export swallows errors and reports them but doesn't show the offending code unless --debug is used.