My code gives the error "Please check if you have Photoshop installed correctly."
See original GitHub issueHello, I’m trying to collect information from a user using telegram chat (pyTelegramBotAPI) so I can transfer this to photoshop inside the function in the future, but when I use the bot, the code gives the error “Please check if you have Photoshop installed correctly.” Although if you run the same, but not through the bot everything will run and work fine.
I tried - get a newer version of photoshop (CC2018 -> 2020), and also specify the path in the Windows environment variables. If you open photoshop using pyWin32 it works fine, but it’s very unprofitable for me, I was going to use only pythonPhotoshopAPI.
Here’s the function
def test_edit_text(info_from):
try:
psApp = ps.Application()
psApp.Open(r"mypath\first.psd")
doc = psApp.Application.ActiveDocument
print(info_from['test'])
text_from_user = info_from['test']
layer1init = doc.ArtLayers["layer1"]
text_new_layer1 = layer1init.TextItem
text_new_layer1 .contents = f"{text_from_user .upper()}"
options = ps.JPEGSaveOptions(quality=5)
jpg = r'mypath\photo.jpg'
doc.saveAs(jpg, options, True)
except Exception as e:
print(e)
If you run the function like this, nothing works
@bot.message_handler(content_types=['text'])
def func(message):
if(message.text == '/ph'): #Here we send a request to the function via telegram chat
user_info = {'test' : 'asdsaasd'}
test_edit_text(user_info)
But if you run it like this, it works fine
if __name__ == '__main__':
user_info = {'test' : 'asdsaasd'}
test_edit_text(user_info) `
Why does the code suddenly stop seeing Photoshop? Is it possible that the two libraries are incompatible?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Hi @emogothyy We only have two places that have
Please check if you have Photoshop installed correctly.
https://github.com/loonghao/photoshop-python-api/blob/main/photoshop/api/_core.py#L43 https://github.com/loonghao/photoshop-python-api/blob/main/photoshop/api/_core.py#L97This API then relies on having Photoshop installed locally, You can try to open Photoshop manually first, and then start your bot server to test.
If possible, please take a screenshot of your running process so that we can take a look
I checked that the dependencies between the two sides are not in conflict.
I tried this method, but these places still have the same error, maybe the problem is in my photoshop, even after reinstalling, but if as before open with os or just open, everything works fine. Thanks so much for helping me with this error. Can I close the issue as solved?