์ž˜ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋˜ Alfred workflow๊ฐ€ ๋™์ž‘ํ•˜์ง€ ์•Š๋Š”๋‹ค.. Mac OS 12.3์œผ๋กœ ์—…๋ฐ์ดํŠธํ•˜๊ณ ๋‚˜์„œ ๋ฐ”๋กœ ์ด๋Ÿฐ ์ด์Šˆ๊ฐ€ ํ„ฐ์ง€๋‹ค๋‹ˆ. ์†๋„๊ฐ€ ์•ˆ๋‚˜ ๋‹ต๋‹ตํ•˜๋‹ค.

Issue ์›์ธ

Apple์—์„œ 12.3๋ถ€ํ„ฐ ๊ณต์‹์ ์œผ๋กœ python 2์„ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค๊ณ  ํ•œ๋‹ค. Python 2๋Š” ์ด์ œ ์ง€์›๋„ ์•ˆํ•ด์ฃผ๋‹ˆ ๋ญ ์ดํ•ด๋Š” ๊ฐ„๋‹ค.

๋ฌธ์ œ๋Š” Alfred workflow๊ฐ€ **Python 2 ๋ฒ„์ „๋งŒ์„ ์ง€์›**ํ•œ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. (ํ•˜..)

Alfred-Workflow only officially supports the system Pythons that come with macOS (i.e. /usr/bin/python), which is 2.6 on 10.6/Snow Leopard and 2.7 on later versions.

๊ทธ๋ž˜์„œ Workflow ์ œ์ž‘์ž๋“ค์ด Python library์ธ Alfred-Workflow๋กœ ์ œ์ž‘ํ•œ ๊ฒฝ์šฐ ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ์•ˆ๋จน์–ด์„œ ์ด ๋ฌธ์ œ๊ฐ€ ํ„ฐ์ง„ ๊ฒƒ.

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์€ ๊ฐ„๋‹จํ•˜๋‹ค. python2๋ฅผ ์ผ๋‹จ ๋‹ค์‹œ ๋ฐ›์ž.

export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
eval "$(brew shellenv)"
brew install pyenv
pyenv install 2.7.18
ln -s "${HOME}/.pyenv/versions/2.7.18/bin/python2.7" "${HOMEBREW_PREFIX}/bin/python"

์œ„์˜ ์ปค๋งจ๋“œ๋ฅผ ํ•˜๋‚˜์”ฉ ๋”ฐ๋ผ ์ณ์ฃผ์ž. ๊ทธ๋Ÿฌ๋ฉด ์ด์ œ python 2.7์ด ์„ค์น˜๋˜์—ˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ์ด๋ ‡๊ฒŒ๋งŒ ํ–ˆ๋‹ค๊ณ  ์ ์šฉ๋˜๋Š” ๊ฑด ์•„๋‹ˆ๋‹ค. python2๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” workflow๋กœ ๊ฐ€์„œ python ์‹คํ–‰ ์œ„์น˜๋ฅผ ์ง€์ •ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค.

์ž˜ ์•ˆ๋ณด์ด๋Š”๋ฐ ์ด๋ ‡๊ฒŒ ๋ณ€๊ฒฝํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

# From
python filename.py "{query}"
 
# To
${HOME}/.pyenv/versions/2.7.18/bin/python filename.py "{query}"

์ด๋ ‡๊ฒŒ ํ•ด๋„ ์•ˆ๋˜๋Š” ๋…€์„์ด ์žˆ์—ˆ๋‹ค.. (Pows)

๋‹คํ–‰ํžˆ migration์„ ํ•ด์ค€ ์šฉ์ž๋‹˜์ด ๊ณ„์…จ๋‹ค. ๋•กํ!

์•ˆ๋œ๋‹ค.. ๊ทธ๋ž˜์„œ ๊ทธ๋ƒฅ python2๋กœ ์‹œ๋„ํ•ด๋ณธ ๊ฒฐ๊ณผ

Traceback (most recent call last):
  File "/Users/user/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.C9F20046-9639-4B9A-B500-C54916D16E75/workflow/workflow.py", line 2070, in run
    self.check_update()
  File "/Users/user/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.C9F20046-9639-4B9A-B500-C54916D16E75/workflow/workflow.py", line 2340, in check_update
    run_in_background('__workflow_update_check', cmd)
  File "/Users/user/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.C9F20046-9639-4B9A-B500-C54916D16E75/workflow/background.py", line 235, in run_in_background
    retcode = subprocess.call(cmd)
  File "/Users/user/.pyenv/versions/2.7.18/lib/python2.7/subprocess.py", line 172, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/Users/user/.pyenv/versions/2.7.18/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/Users/user/.pyenv/versions/2.7.18/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

??? ์ด๊ฑด ๋˜ ๋ญ์•ผ. ์ž˜ ๋ณด๋‹ˆ subprocess.py๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค๊ณ  ํ•œ๋‹ค. OSError: [Errno 2] No such file or directory while using python subprocess in Django ํ•ด๋‹น ๊ธ€์„ ๋ณด๋‹ˆ ํ•จ์ˆ˜ ํ˜ธ์ถœ์ด ์ž˜๋ชป ๋œ ๊ฒƒ ๊ฐ™๋‹ค.

์‹ค์ œ๋กœ ์—๋Ÿฌ ๋กœ๊ทธ๋ณด๋‹ˆ retcode = subprocess.call(cmd) ์ด๋ถ€๋ถ„ ์„ค๋ช…๊ณผ ๊ฐ™์•˜๋‹ค.

๊ทธ๋ž˜์„œ ํ•ด๋‹น ๊ฒฝ๋กœ๋กœ ๊ฐ€์„œ ๋ฐ”๊ฟ”์คฌ๋‹ค.

# From
retcode = subprocess.call(crop)
 
# To
retcode = subprocess.call(crop, shell=True)

๊ทธ๋ฆฌ๊ณ  python 2๋กœ ๋ช…๋ น์–ด๋ฅผ ๋ฐ”๊ฟ”์ฃผ๋‹ˆ ๋œ๋‹ค!

๋งˆ๋ฌด๋ฆฌ

ํ•˜, ๊ฐ‘์ž๊ธฐ ์•ˆ๋˜์„œ ํ˜ˆ์••์ด ์˜ฌ๋ผ๋ฒ„๋ ธ๋‹ค. ์ด์ œ Script์งœ์„œ ์ž๋™ํ™” ๋งŒ๋“ค์–ด๋‘ฌ์•ผ ๋˜๋„ค..? ๊ท€์ฐฎ๋‹ค. ๋!

Reference