如果有人可以帮我解决这个问题,那会很好,现在已经把头发撕掉了一段时间。我一直在尝试使用pyinstaller将Kivy应用程序编译为.exe。它在我的基础Anaconda env中运行良好,但是生成的.exe文件夹是500mb ...所以为了使它更小我正在制作一个只有所需包的新环境。在我尝试过的所有内容之后,它始终以
结束IndexError:列表索引超出范围 [4160]无法执行脚本demoplayer
以下是完整的错误消息:
searchResultController
我的.spec文件:
(reflexlast) C:\Users\Jesse\reflv01\dist\demoplayer>demoplayer.exe
[INFO ] [Logger ] Record log in C:\Users\Jesse\.kivy\logs\kivy_18-02-14_3
8.txt
[INFO ] [Kivy ] v1.10.0
[INFO ] [Python ] v3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32
) [MSC v.1900 64 bit (AMD64)]
[INFO ] [Factory ] 194 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil
, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
Traceback (most recent call last):
File "demoplayer.py", line 7, in <module>
from pywinauto import application
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\users\jesse\anaconda3\envs\reflexlast\lib\site-packages\PyInstaller\
loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pywinauto\__init__.py", line 72, in <module>
them.
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\users\jesse\anaconda3\envs\reflexlast\lib\site-packages\PyInstaller\
loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pywinauto\findwindows.py", line 42, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\users\jesse\anaconda3\envs\reflexlast\lib\site-packages\PyInstaller\
loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pywinauto\controls\__init__.py", line 36, in <module>
To activate a module this way, you can edit your configuration file (in you
r
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\users\jesse\anaconda3\envs\reflexlast\lib\site-packages\PyInstaller\
loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pywinauto\controls\uiawrapper.py", line 46, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\users\jesse\anaconda3\envs\reflexlast\lib\site-packages\PyInstaller\
loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pywinauto\uia_defines.py", line 35, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\users\jesse\anaconda3\envs\reflexlast\lib\site-packages\PyInstaller\
loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\comtypes\client\__init__.py", line 33, in <module>
Activate a module in the config
File "site-packages\comtypes\client\_code_cache.py", line 71, in _find_gen_di
r
IndexError: list index out of range
[4160] Failed to execute script demoplayer
使用Windows 7 64位,python 3.6.4 64位
我一开始认为这可能是因为丢失了包,但我不知道如何找出哪些......或者我的spec文件中缺少什么? 我的基础环境有~500个包,kivy app env~30。任何帮助将不胜感激!
答案 0 :(得分:1)
好的,如果有人有类似的问题:显然pyinstaller有pywinauto包的麻烦
import java.util.*;
public class assignment052 {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
int userGuess = 0;
int compNum = 0;
int guess = 0;
int totalGuesses = 0; //
int best = 9999; //
introduction();
int games = 0;
String playAgain = "y";
while(playAgain.equalsIgnoreCase("y")) {
System.out.println();
System.out.println("I'm thinking of a number between 1 and 100...");
games++;
guessNumber(console, userGuess, compNum, guess);
System.out.println(guess);
totalGuesses += guess;
System.out.println("Do you want to play again?");
Scanner newGame = new Scanner(System.in);
playAgain = newGame.next();
if (best > guess) { //
best = guess; //
}
}
result(games, totalGuesses, best);
}
// Method that introduces the game
public static void introduction() {
System.out.println("This program allows you to play a guessing game.");
System.out.println("I will think of a number between 1 and");
System.out.println("100 and will allow you to guess until");
System.out.println("you get it. For each guess, I will tell you");
System.out.println("whether the right answer is higher or lower");
System.out.println("than your guess.");
}
// method to play 1 game
public static double guessNumber(Scanner console, int userGuess, int compNum, int guess) {
Random rand = new Random();
userGuess = console.nextInt();
guess = 1;
compNum = rand.nextInt(100)+1;
while(compNum != userGuess) {
if(compNum > userGuess) {
System.out.println("It's higher.");
} else {
System.out.println("It's lower.");
}
guess++;
userGuess = console.nextInt();
}
System.out.println("you got it right in " + guess + " guesses");
return guess;
}
// method for overall result
public static void result(int games, int totalGuesses, int best) {
System.out.println("Overall results:");
System.out.println();
System.out.println("Total games played : " + games);
System.out.println("Total guesses : " + totalGuesses);
System.out.println("Guesses per game : " + totalGuesses / games);
}
特别是pyinstaller无法找到pywinauto的comtypes文件夹。这个帖子帮助我解决了这个问题: