0

Code won`t launch in VS code but works fine if launched with python IDLE

zoom=locateCenterOnScreen("zoombar.png", confidence=0.7) zoombar.png is located at the same folder as .py This line of code behaves different if launched with VS code of with python IDLE If launched with VS code we get error: OSError: Failed to read zoombar.png because file is missing, has improper permissions, or is an unsupported or invalid format But if launched with IDLE it works fine How can i fix it to work in VS code, without typing full path of .png`s ( can`t do this because im going to send this code to another person who won`t have exact same path)

14th Apr 2022, 2:53 PM
Artur
Artur - avatar
14 Respuestas
+ 1
Is your visual studio the right version?
16th Apr 2022, 7:30 AM
Chris
Chris - avatar
+ 1
Ok, have you got .vscode file in vs?
16th Apr 2022, 7:36 AM
Chris
Chris - avatar
+ 1
Yeah, the only problem is that VS cant locate my file if i declare it like "123.png", must be "full_path//123.png". If i run the code using python shell it works
16th Apr 2022, 7:39 AM
Artur
Artur - avatar
+ 1
Ahhh
16th Apr 2022, 8:05 AM
Chris
Chris - avatar
+ 1
Like this? - ________________________ | .vscode | | file | | main.py | | example.png _________________________ Can the img load?
16th Apr 2022, 8:59 AM
Chris
Chris - avatar
+ 1
Wow, ty. I have 1 more question where do i need to create project to avoid manually dragging png's?
16th Apr 2022, 9:05 AM
Artur
Artur - avatar
+ 1
Try creating a pyautogui bot to do it, np 🙂
16th Apr 2022, 9:07 AM
Chris
Chris - avatar
0
In the terminal of VS code, go to the folder where Ur .Py and the image is and then run the code
14th Apr 2022, 3:01 PM
Jolen Mascarenhas
0
I think so, installed it 10 days ago
16th Apr 2022, 7:33 AM
Artur
Artur - avatar
0
Open vscode in full screen, open the file location of your png image, drag and drop it into your project folder (hope this helps 🙂)
16th Apr 2022, 8:07 AM
Chris
Chris - avatar
0
project.py and .png's are located in the same folder
16th Apr 2022, 8:17 AM
Artur
Artur - avatar
0
I made folder at desktop and put .py and png's here. After that i right click .py and open with Code
16th Apr 2022, 9:01 AM
Artur
Artur - avatar
0
Ohh, drag and drop png into vs
16th Apr 2022, 9:01 AM
Chris
Chris - avatar