how to use exe(use pyinstaller output)in sikuli

Asked by wu on 2019-10-30

i have the py and i want to use this in my sikuli so i use pyinstaller to output the exe and use app open(exe) or os.system(exe)

but my py include the txt path to do something when i use the exe in sikuli(1.1.4) and the sikuli will tell me can't find the txt。

  k = open('XXX.txt')
for i in k:

and in sikuli:
  os.system('path.test.exe') or'path.test.ext')

PS: the txt alaways toghter with the

 i use the sys.path[0] the sikuli will jump to sikuil's now path

have some anwser to fixed this?

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

I have no idea what you are talking about: - pyinstaller - exe

Where is the text file with the exe?

wu (chouhua) said : #2

simple: i have a the content is open a 123.txt and use the 123.txt content to do something。
     a = open('123.txt')
     for i in a:
and i use pyinstaller to package the to test.exe。

then my sikuli code will use'test.exe') or os.system('test.exe')

but will tell me can't not find the 123.txt but the 123.txt will put in the folder with test.exe

begin i guess maybe is the test.exe path error so i change write use 【a = open(sys.path[0]+'\123.txt'】the sys.path[0] will print now

the exe path and can find the 123.txt. but use in sikuli will jump to the temp folder, so i have no idea to solve the question

Manfred Hampl (m-hampl) said : #3

Is the 123.txt file packaged inside the test.exe application, or is this a file on the hard disk of the target computer?

Have you tried providing the full path of this file, e.g. something like a = open("C:\\users\\wu\\myfiles\\123.txt")

wu (chouhua) said : #4


the 123.txt is on the hard disk of the target computer but not packaged inside the test.exe,just give test.exe the txt path。
and the 123.txt 、test.exeis put togather in the folder

and another i already tried providing the full path . just like you write

a = open("C:\\users\\wu\\myfiles\\123.txt")

Manfred Hampl (m-hampl) said : #5

What happens if you execute test.exe outside sikuli, just from a command window?

General remark:
Whenever you get an error message, please provide the full text, not just a short note like "and the sikuli will tell me can't find the txt"

wu (chouhua) said : #6

OK will File, line6 in<module>
FileNotFoundError: [Errno2] no such file or directory:'123.txt'
[5912] Failed to execute script test

that is use sikuli and error log in cmd

Manfred Hampl (m-hampl) said : #7

If you get this error message when executing test.exe in a cmd window, then this is not an error message from Sikuli, but an error message from test.exe.

Your test.exe has a problem, that it cannot find 123.txt.

You have to correct your script and create a new test.exe program which works and does not give an error.

wu (chouhua) said : #8

@Manfred Hampl this error is when i use sikuli to ues the test.exe will get , simple use test.exe in cmd is work good ,but in sikuli will not work and get i tell you the error .

Manfred Hampl (m-hampl) said : #9

What is the current contents of, especially with respect to the file name and its path?

wu (chouhua) said : #10

@Manfred Hampl the
a = open('123.txt')
for i in a:

Manfred Hampl (m-hampl) said : #11

Try the following:

Open a command line window,
change directory to a different directory than the one with test.exe,
and then execute …path…\text.exe (with the correct path given).

What do you get?

wu (chouhua) said : #12

@Manfred Hampl

i got like sikuli to get

Traceback (most recent call last):
  File "", line 6, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '123.txt'
[13360] Failed to execute script test

Manfred Hampl (m-hampl) said : #13

That is what I meant.

The error message does not come from Sikuli, but is coming from test.exe (or

I suggest that you provide the full path to the 123.txt file in the open() statement in

a = open('c:\\whatever_the_path_is\\123.txt')
for i in a:

This should then work outside and inside Sikuli.

Can you help with this problem?

Provide an answer of your own, or ask wu for more information if necessary.

To post a message you must log in.