photoshop-python-api
photoshop-python-api copied to clipboard
error when working with photoshop since version 23.5
Describe the bug An error occurs when opening a session or when trying to call the add method on a document.
To Reproduce Steps to reproduce the behavior:
- Run "hello world" example
- See error
StackTrace
(env) PS D:\projects\python\test> python ony.py
Traceback (most recent call last):
File "D:\projects\python\test\ony.py", line 3, in
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\projects\python\test\ony.py", line 7, in
Desktop (please complete the following information):
- OS: Windows11 22H2
- Photoshop Version: 23.5.2 and 24
- Python Version: 3.10.8
Unfortunately, my system has not been updated to windows11 for a while, so I can't test it for you. theoretically compatible.
@loonghao Checked on Windows 10 and the problem persists. The problem occurs when switching from Photoshop version 23.4 to 23.5 and higher
@vladislavmass I have tested use python-3.10.8 in Photoshop 2022(23.5.2) , that is working.

@loonghao 24 version also works for you without problems?
@loonghao 24 version also works for you without problems?
Since 24 version doesn't support my current system version (win10), I can't test
@vladislavmass This is kind of a notorious problem unfortunately, its not the Photoshop version. In my experience updating Photoshop or installing a newer version atop an older version can just break the ability to communicate with it using the API/COM/RCP whatever system. If you update Photoshop and find that it doesn't work, my advice would be to completely uninstall Photoshop from your system and then install the latest from fresh. It should work after that (sometimes I've had to do this twice). Also, another caution: The API ESPECIALLY does not like having two versions of Photoshop installed, never install two versions of Photoshop, it pretty much breaks scripting altogether (javascript and python)
@loonghao I believe Photoshop 24 does support Win10 as long as you've received the latest windows update/service pack, or am I wrong? That would be crazy if Adobe requires an update to Win11 altogether..
@MrTeferi reinstalling helped with version 23. This is not the case with version 24. I reinstalled it 10 times already and it doesn't work. At the same time, the connection with Photoshop is clearly established. And then there are errors.
@loonghao If you believe the official documentation of Photoshop, then it supports Windows 10 with update 21h1
Thật không may, đây là một vấn đề khét tiếng, nó không phải là phiên bản Photoshop. Theo kinh nghiệm của tôi, cập nhật Photoshop hoặc cài đặt phiên bản mới hơn trên phiên bản cũ hơn chỉ có thể phá vỡ khả năng giao tiếp với nó bằng cách sử dụng API / COM / RCP bất kỳ hệ thống nào. Nếu bạn cập nhật Photoshop và thấy rằng nó không hoạt động, lời khuyên của tôi là gỡ cài đặt hoàn toàn Photoshop khỏi hệ thống của bạn và sau đó cài đặt phiên bản mới nhất từ mới. Nó sẽ hoạt động sau đó (đôi khi tôi đã phải làm điều này hai lần). Ngoài ra, một cảnh báo khác: API ĐẶC BIỆT không thích cài đặt hai phiên bản Photoshop, không bao giờ cài đặt hai phiên bản Photoshop, nó phá vỡ hoàn toàn kịch bản (javascript và python)
I also have the same problem when running from 2 photoshop applications, I don't know how to specify the photoshop version or copy the reg of that photoshop version
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
Unfortunately, this is a notorious problem, it's not specific to the Photoshop version. In my experience, updating Photoshop or installing a newer version on top of an older version can just break the ability to communicate with it using API/COM/RCP whatever the system is. If you update Photoshop and find that it doesn't work, my advice is to completely uninstall Photoshop from your system and then install the latest version from fresh. It should work after that (sometimes I've had to do this twice). Also, another warning: API SPECIFICALLY does not like installing two versions of Photoshop, never install two versions of Photoshop, it completely breaks the script (javascript and python)
I also have the same problem when running from 2 photoshop applications, I don't know how to specify the photoshop version or copy the reg of that photoshop version
@vladislavmass
@MrTeferi reinstalling helped with version 23. This is not the case with version 24. I reinstalled it 10 times already and it doesn't work. At the same time, the connection with Photoshop is clearly established. And then there are errors.
I know this is an old comment, but if you still have this issue, sometimes it isn't enough to uninstall Photoshop and reinstall. Sometimes registry information can persist through installs (which is what causes all of these issues, mismatch in registry data that is used to communicate with the correct Photoshop application and components). After uninstalling Photoshop, in registry go to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Adobe and delete the "Photoshop" folder. Then in registry go to Computer\HKEY_CURRENT_USER\Software\Adobe and delete "Photoshop" there as well. Then in registry go to Computer\HKEY_CLASSES_ROOT and scroll down until you get to the entries starting with P, look for anything with "Photoshop.", each of these entries governs different components of Photoshop, things like "Photoshop.ActionDescriptor", "Photoshop.Application", etc. Delete any of these starting with "Photoshop." After that, reinstalling Photoshop should add new registry entries which only match the new Photoshop version, and the API should function fine.
@nqthaivl
I also have the same problem when running from 2 photoshop applications, I don't know how to specify the photoshop version or copy the reg of that photoshop version
When using the API, you can pass a version when creating the Photoshop application object:
from photoshop.api import Application
app = Application('2024')
I cannot remember if there is a way to specify the Beta version of current year over the non-Beta version of current year Photoshop, I believe it is by supplying the actual numeric value of the version in question but I'll have to refresh on that. For most people, simply opening Photoshop first before you use the API will ensure the API uses the one that is already running, but again this depends on some system level stuff that might be different from person to person, ymmv. I've designed a lot of ways around this myself in my app, feel free to check my implementation. You can find the components I built on top of the Photoshop application object in src/utils/adobe.py.
One thing that is particularly important when it comes to specifying which version of Photoshop to use, is that the very first Photoshop object that is initialized in your app MUST specify the version. Once the version has been specified, any Photoshop related object you use after that will automatically pickup an os.environ variable that is established when the first object is initialized. That environ variable ensures that any subequent COM calls to establish a Photoshop object will ask for the version you specified. If you don't specify the version in the very first object that is initialized, then specifying a version later may cause COM system errors since the different COM objects will be in conflict with one another.