icloud_photo_station icon indicating copy to clipboard operation
icloud_photo_station copied to clipboard

Cannot run icloudpd.py on DSM 7

Open billyschonenberg opened this issue 3 years ago • 1 comments

Overview

I cannot run icloudpd.py on dsm 7( DSM 7.0.1-42218 ).

When running I see : ModuleNotFoundError: No module named 'click'.

Steps to Reproduce

  1. Manually install 0.3.0 spk from repo ( or build spk from source and then install)
  2. run the scripts (either manually from command line or in task scheduler:
  3. source /volume1/@appstore/icloud_photo_station/env/bin/activate
    python /volume1/@appstore/icloud_photo_station/app/icloudpd.py \
        --username '<YOUR ICLOUD USERNAME>' \
        --password '<YOUR ICLOUD PASSWORD>' \
        --auto-delete \
        --until-found 10 \
        --directory ./output/```
    

4: output

Traceback (most recent call last):
File "/volume1/@appstore/icloud_photo_station/app/icloudpd.py", line 2, in <module>
 from icloudpd.base import main
File "/volume1/@appstore/icloud_photo_station/app/icloudpd/base.py", line 12, in <module>
 import click
ModuleNotFoundError: No module named 'click'

Context

There seems to be going something wrong with installing the requirements with pip:

(env) Billy@Rubin:~$ pip install -r  ~/requirements.txt 
Collecting pyicloud_ipd==0.10.1
  Using cached pyicloud_ipd-0.10.1-py2.py3-none-any.whl (22 kB)
Collecting schema==0.7.4
  Using cached schema-0.7.4-py2.py3-none-any.whl (16 kB)
Collecting click==6.7
  Using cached click-6.7-py2.py3-none-any.whl (71 kB)
Collecting python_dateutil==2.8.2
  Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting requests>=2.20.0
  Using cached requests-2.27.1-py2.py3-none-any.whl (63 kB)
Collecting tqdm==4.62.0
  Using cached tqdm-4.62.0-py2.py3-none-any.whl (76 kB)
Collecting piexif==1.1.3
  Using cached piexif-1.1.3-py2.py3-none-any.whl (20 kB)
Collecting certifi
  Using cached certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
Collecting pytz
  Using cached pytz-2021.3-py2.py3-none-any.whl (503 kB)
Collecting six>=1.9.0
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting keyrings.alt<2.0,>=1.0
  Using cached keyrings.alt-1.3-py2.py3-none-any.whl (21 kB)
Collecting future
  Using cached future-0.18.2-py3-none-any.whl
Collecting tzlocal
  Using cached tzlocal-4.1-py3-none-any.whl (19 kB)
Collecting keyring<9.0,>=8.0
  Using cached keyring-8.7-py2.py3-none-any.whl (33 kB)
Collecting contextlib2>=0.5.5
  Using cached contextlib2-21.6.0-py2.py3-none-any.whl (13 kB)
Collecting charset-normalizer~=2.0.0
  Using cached charset_normalizer-2.0.10-py3-none-any.whl (39 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.3-py3-none-any.whl (61 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.7-py2.py3-none-any.whl (138 kB)
Collecting backports.zoneinfo
  Using cached backports.zoneinfo-0.2.1.tar.gz (74 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting pytz-deprecation-shim
  Using cached pytz_deprecation_shim-0.1.0.post0-py2.py3-none-any.whl (15 kB)
Collecting tzdata
  Using cached tzdata-2021.5-py2.py3-none-any.whl (339 kB)
Building wheels for collected packages: backports.zoneinfo
  Building wheel for backports.zoneinfo (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
   command: /volume1/@appstore/icloud_photo_station/env/bin/python /volume1/@appstore/icloud_photo_station/env/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpppzdlxpy
       cwd: /tmp/pip-install-26l01u8j/backports-zoneinfo_fe39e2ea05074c64abaf4a82b2051a2f
  Complete output (26 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-armv7l-3.8
  creating build/lib.linux-armv7l-3.8/backports
  copying src/backports/__init__.py -> build/lib.linux-armv7l-3.8/backports
  creating build/lib.linux-armv7l-3.8/backports/zoneinfo
  copying src/backports/zoneinfo/_zoneinfo.py -> build/lib.linux-armv7l-3.8/backports/zoneinfo
  copying src/backports/zoneinfo/_version.py -> build/lib.linux-armv7l-3.8/backports/zoneinfo
  copying src/backports/zoneinfo/_tzpath.py -> build/lib.linux-armv7l-3.8/backports/zoneinfo
  copying src/backports/zoneinfo/_common.py -> build/lib.linux-armv7l-3.8/backports/zoneinfo
  copying src/backports/zoneinfo/__init__.py -> build/lib.linux-armv7l-3.8/backports/zoneinfo
  running egg_info
  warning: no files found matching '*.png' under directory 'docs'
  warning: no files found matching '*.svg' under directory 'docs'
  no previously-included directories found matching 'docs/_build'
  no previously-included directories found matching 'docs/_output'
  writing manifest file 'src/backports.zoneinfo.egg-info/SOURCES.txt'
  copying src/backports/zoneinfo/__init__.pyi -> build/lib.linux-armv7l-3.8/backports/zoneinfo
  copying src/backports/zoneinfo/py.typed -> build/lib.linux-armv7l-3.8/backports/zoneinfo
  running build_ext
  creating build/temp.linux-armv7l-3.8
  creating build/temp.linux-armv7l-3.8/lib
  /usr/local/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-wrap-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DOPENSSL_NO_SSL3 -DOPENSSL_NO_SSL2 -I/usr/local/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/usr/include -DSYNOPLAT_F_ARMV7 -O2 -mcpu=cortex-a9 -march=armv7-a -mfpu=neon -mfloat-abi=hard -mthumb -fno-diagnostics-show-caret -Wno-unused-local-typedefs -include /usr/syno/include/platformconfig.h -DSYNO_ENVIRONMENT -DBUILD_ARCH=32 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DSYNO_RUNNING_DSM_BUILD_SYSTEM -g -pipe -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result -fPIC -I/volume1/@appstore/icloud_photo_station/env/include/python3.8 -c lib/zoneinfo_module.c -o build/temp.linux-armv7l-3.8/lib/zoneinfo_module.o -std=c99
  error: command '/usr/local/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-wrap-gcc' failed: No such file or directory
  ----------------------------------------
  ERROR: Failed building wheel for backports.zoneinfo
Failed to build backports.zoneinfo
ERROR: Could not build wheels for backports.zoneinfo, which is required to install pyproject.toml-based projects

environment:

(env) Billy@Rubin:~$ pip --version
^[[A^[[Apip 21.3.1 from /volume1/@appstore/icloud_photo_station/env/lib/python3.8/site-packages/pip (python 3.8)
^[[B(env) Billy@Rubin:~$ python --version
Python 3.8.8
(env) Billy@Rubin:~$ which python
/volume1/@appstore/icloud_photo_station/env/bin/python
(env) Billy@Rubin:~$ which pip
/volume1/@appstore/icloud_photo_station/env/bin/pip
(env) Billy@Rubin:~$  python /volume1/@appstore/icloud_photo_station/app/icloudpd.py         --username 'test'         --password 'redacted'         --auto-delete         --until-found 10         --directory ./output/
Traceback (most recent call last):
  File "/volume1/@appstore/icloud_photo_station/app/icloudpd.py", line 2, in <module>
    from icloudpd.base import main
  File "/volume1/@appstore/icloud_photo_station/app/icloudpd/base.py", line 12, in <module>
    import click
ModuleNotFoundError: No module named 'click'
(env) Billy@Rubin:~$ 

billyschonenberg avatar Jan 07 '22 10:01 billyschonenberg

I'm not sure if this package is still maintained, but I had the same issue. As the error trace suggests, the issue appears to be installing the 'backports.zoneinfo' package. It turns out this isn't required in python 3.9, so my workaround was:

  1. Install the Python 3.9 package in package manager
  2. Create a Python 3.9 virtual environment in the '/volume1/@appstore/icloud_photo_station' folder.
  3. Manually install the packages from requirements.txt in this venv

Running icloudpd.py within the new Python 3.9 venv works perfectly for me.

matthewroche avatar Mar 22 '22 21:03 matthewroche

Just wanted to add some detail. Mostly so I can remember it the next time...! :)

  1. install Python 3.9 (from the Synology Package Station)

  2. install icloud_photo_station-0.3.0.spk package manually from skarppi / icloud_photo_station

  3. ssh into the Synology box

  4. change ownership of the folder: sudo chown -R icloud_photo_station:users /volume1/\@appstore/icloud_photo_station/

  5. change into the folder: cd /volume1/\@appstore/icloud_photo_station

  6. recursively fix permissions of folders and files: sudo find . -type d -exec chmod 0755 {} \; sudo find . -type f -exec chmod 0644 {} \;

  7. move the old environment: mv env env.old

  8. make a new environment with Python3.9: /volume1/\@appstore/Python3.9/usr/bin/python -m venv env

  9. change into the environment: source /volume1/\@appstore/icloud_photo_station/env/bin/activate

  10. get the dependencies list: curl -O https://raw.githubusercontent.com/skarppi/icloud_photo_station/master/requirements.txt

  11. install the dependencies: pip install -r requirements.txt

  12. test and activate 2FA: python /volume1/\@appstore/icloud_photo_station/app/icloudpd.py --list-albums

  13. deactivate the environment: deactivate

Now should work from the Synology Scheduler ... :)

It may be useful to have a script in your home folder to trigger 2FA when needed (edit for your login details):

Install 'SynoCLI File Tools' for nano editor, then: nano ~/trigger2FA.sh, paste:

#!/bin/bash
source /volume1/@appstore/icloud_photo_station/env/bin/activate
python /volume1/@appstore/icloud_photo_station/app/icloudpd.py \
  --username '<YOUR ICLOUD USERNAME>' \
  --password '<YOUR ICLOUD PASSWORD>' \
  --list-albums

Change the permissions:chmod 700 ~/trigger2FA.sh

Run: ~/trigger2FA.sh

transilluminate avatar Mar 01 '23 21:03 transilluminate

It looks like backports.zoneinfo isn't even needed anymore with the default Python 3.8 available in current DSM 7.2-64570. So I removed the whole dependency from the latest 0.4.1 release. Seems to be working now with both the Python 3.8 and 3.9 versions.

skarppi avatar Jan 20 '24 11:01 skarppi