Copy link to clipboard
Copied
Hello,
i wrote a python script (version3.10 in my computer) which is called by a lua script in lightroom 14.4. The python version called by the lua script is version 3.9.6 of python, that i dont find in my computer
my command in my lua file is:
local command = 'python3 ' ..'"'.. scriptPath .. '" ' ..'"'.. path .. '"'
The question is where is the version of python that lua lightroom uses ? Is it possible to change it ?
Thank you very much
[This post contains formatting and embedded images that don't appear in email. View the post in your Web browser.]
LR doesn't include "python3". The built-in Aperture/iPhoto Importer Plugin runs Python scripts, but it relies on the standard version of Python included with Mac OS. (The plugin doesn't run on Windows.)
LrTasks.execute() runs its scripts in an environment with a default PATH variable that's not the PATH set by your login shell. So you're getting the default Mac OS "python3" (3.9.6
...Copy link to clipboard
Copied
What do you get when you run these commands (in bold) from Terminal?
$ which python3
/opt/homebrew/bin/python3
$ $(which python3) -V
Python 3.13.5
Copy link to clipboard
Copied
These are the responses:
marcbarbier@iMac-de-Marc ~ % which python3
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3
marcbarbier@iMac-de-Marc ~ % $(which python3) -V
Python 3.10.1
Copy link to clipboard
Copied
[This post contains formatting and embedded images that don't appear in email. View the post in your Web browser.]
LR doesn't include "python3". The built-in Aperture/iPhoto Importer Plugin runs Python scripts, but it relies on the standard version of Python included with Mac OS. (The plugin doesn't run on Windows.)
LrTasks.execute() runs its scripts in an environment with a default PATH variable that's not the PATH set by your login shell. So you're getting the default Mac OS "python3" (3.9.6 on Mac OS 15).
You can see this explicitly by placing the following Lua script "which-python.lua" in the Lightroom Scripts folder:
~/Library/Application Support/Adobe/Lightroom/Scriptsrestarting LR, and then doing the menu command Scripts > which-python. It will show this:
So your LrTasks.execute() will have to explicitly set a different PATH or refer to the absolute path of the desired "python3".
which-python.lua:
local LrDialogs = import "LrDialogs"
local LrFileUtils = import "LrFileUtils"
local LrPathUtils = import "LrPathUtils"
local LrTasks = import "LrTasks"
LrTasks.startAsyncTask (function ()
local out = LrPathUtils.standardizePath ("~/Desktop/out.txt")
local cmd = "(/bin/echo -n 'which: '; which -a python3; " ..
"/bin/echo -n 'Version: '; python3 -V; " ..
"/bin/echo 'PATH: ' $PATH) >" .. out
LrTasks.execute (cmd)
LrDialogs.message ("Output", LrFileUtils.readFile (out))
end)
Copy link to clipboard
Copied
Thank you i will try it and i say you what happens.
Copy link to clipboard
Copied
Hello John
Very good it works perfectly when i give the path of python 3.10.
Here is my code to call python script with a parameter (path of a lightroom image):
local scriptPath = '"/Volumes/....../myscript.py" '
local catalog = LrApplication:activeCatalog()
local image = catalog:getTargetPhoto() -- photo en cours
local path = '"'..image.path..'"'
local py = '"/Library/Frameworks/Python.framework/Versions/3.10/bin/python3" '
local command = py .. scriptPath .. path
local process = io.popen(command, 'r')
local output = process:read('*a')
local exitCode = process:close()
It is necessary to be VERY VERY careful with the blanks between parameters of the command, i lost much time for that.
Here is the result in lightroom
import sys OK
import os OK
python 3.10.1 (v3.10.1:2cd268a3a9, Dec 6 2021, 14:28:59) [Clang 13.0.0 (clang-1300.0.29.3)]
Thank you so much for help
Copy link to clipboard
Copied
Use PyInstaller to create either a Windows exe or an MacOs app version of your Python scripts.
This way you are independant of any Python version installed the computer of yourself or any client.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more