Today I tried to change the end of my code:
---------------------------------------
def main():
automatico_manual()
if __name__ == "__main__":
main()
----------------------------------------
And tried to compile with: python3 -m PyInstaller --onefile --windowed
--hidden-import=tkinter resizer_linux.py
Still the same problem, it wont open with double click, but in terminal
with ./app it works...
Not solved yet :(
Em sábado, 24 de outubro de 2020 às 10:19:31 UTC-4, MrMine Toons escreveu:
> Hi! So, i`m getting too tired in a problem which I cant open my app
> executable in linux with a double click, but it works perfectly when go to
> terminal /dist folder and type ./app
> Actually I tried everything I had found in internet, but none of the
> worked. I tried the when-things-go-wrong.html but it didn't helped me too.
>
> I`m building an app to change the size of a Virtual Machine in Virtual
> Box. It get the .VDI file and edit it to the size which I want. The app
> works fine, it have no problems.
> When I run: python3 -m PyInstaller --onefile --hidden-import=tkinter
> resizer_linux.py
> ---------------------START-------------------------
> 27 INFO: PyInstaller: 4.0
> 27 INFO: Python: 3.8.6
> 34 INFO: Platform: Linux-5.9.0-1-amd64-x86_64-with-glibc2.29
> 34 INFO: wrote
> /home/mrminetoons/Documents/Projetos/Python/SoftgranResizerVM/Resizer
> Linux/resizer_linux.spec
> 37 INFO: UPX is not available.
> 38 INFO: Extending PYTHONPATH with paths
> ['/home/mrminetoons/Documents/Projetos/Python/SoftgranResizerVM/Resizer
> Linux',
> '/home/mrminetoons/Documents/Projetos/Python/SoftgranResizerVM/Resizer
> Linux']
> 42 INFO: checking Analysis
> 42 INFO: Building Analysis because Analysis-00.toc is non existent
> 42 INFO: Initializing module dependency graph...
> 43 INFO: Caching module graph hooks...
> 47 INFO: Analyzing base_library.zip ...
> 1760 INFO: Processing pre-find module path hook distutils from
> '/home/mrminetoons/.local/lib/python3.8/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py'.
> 1760 INFO: distutils: retargeting to non-venv dir '/usr/lib/python3.8'
> 3453 INFO: Caching module dependency graph...
> 3529 INFO: running Analysis Analysis-00.toc
> 3558 INFO: Analyzing
> /home/mrminetoons/Documents/Projetos/Python/SoftgranResizerVM/Resizer
> Linux/resizer_linux.py
> 3574 INFO: Processing module hooks...
> 3575 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from
> '/home/mrminetoons/.local/lib/python3.8/site-packages/PyInstaller/hooks'...
> 3575 INFO: Loading module hook 'hook-sysconfig.py' from
> '/home/mrminetoons/.local/lib/python3.8/site-packages/PyInstaller/hooks'...
> 3580 INFO: Loading module hook 'hook-lib2to3.py' from
> '/home/mrminetoons/.local/lib/python3.8/site-packages/PyInstaller/hooks'...
> 3591 INFO: Loading module hook 'hook-xml.py' from
> '/home/mrminetoons/.local/lib/python3.8/site-packages/PyInstaller/hooks'...
> 3645 INFO: Loading module hook 'hook-_tkinter.py' from
> '/home/mrminetoons/.local/lib/python3.8/site-packages/PyInstaller/hooks'...
> 3692 INFO: checking Tree
> 3693 INFO: Building Tree because Tree-00.toc is non existent
> 3693 INFO: Building Tree Tree-00.toc
> 3697 INFO: checking Tree
> 3697 INFO: Building Tree because Tree-01.toc is non existent
> 3697 INFO: Building Tree Tree-01.toc
> 3698 INFO: Loading module hook 'hook-encodings.py' from
> '/home/mrminetoons/.local/lib/python3.8/site-packages/PyInstaller/hooks'...
> 3727 INFO: Loading module hook 'hook-distutils.py' from
> '/home/mrminetoons/.local/lib/python3.8/site-packages/PyInstaller/hooks'...
> 3736 INFO: Looking for ctypes DLLs
> 3756 INFO: Analyzing run-time hooks ...
> 3759 INFO: Including run-time hook
> '/home/mrminetoons/.local/lib/python3.8/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py'
> 3761 INFO: Including run-time hook
> '/home/mrminetoons/.local/lib/python3.8/site-packages/PyInstaller/hooks/rthooks/pyi_rth__tkinter.py'
> 3766 INFO: Looking for dynamic libraries
> 4169 INFO: Looking for eggs
> 4169 INFO: Python library not in binary dependencies. Doing additional
> searching...
> 4200 INFO: Using Python library /lib/x86_64-linux-gnu/libpython3.8.so.1.0
> 4204 INFO: Warnings written to
> /home/mrminetoons/Documents/Projetos/Python/SoftgranResizerVM/Resizer
> Linux/build/resizer_linux/warn-resizer_linux.txt
> 4226 INFO: Graph cross-reference written to
> /home/mrminetoons/Documents/Projetos/Python/SoftgranResizerVM/Resizer
> Linux/build/resizer_linux/xref-resizer_linux.html
> 4233 INFO: checking PYZ
> 4233 INFO: Building PYZ because PYZ-00.toc is non existent
> 4233 INFO: Building PYZ (ZlibArchive)
> /home/mrminetoons/Documents/Projetos/Python/SoftgranResizerVM/Resizer
> Linux/build/resizer_linux/PYZ-00.pyz
> 4577 INFO: Building PYZ (ZlibArchive)
> /home/mrminetoons/Documents/Projetos/Python/SoftgranResizerVM/Resizer
> Linux/build/resizer_linux/PYZ-00.pyz completed successfully.
> 4579 INFO: checking PKG
> 4579 INFO: Building PKG because PKG-00.toc is non existent
> 4579 INFO: Building PKG (CArchive) PKG-00.pkg
> 8108 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
> 8112 INFO: Bootloader
> /home/mrminetoons/.local/lib/python3.8/site-packages/PyInstaller/bootloader/Linux-64bit/run
> 8112 INFO: checking EXE
> 8112 INFO: Building EXE because EXE-00.toc is non existent
> 8112 INFO: Building EXE from EXE-00.toc
> 8112 INFO: Appending archive to ELF section in EXE
> /home/mrminetoons/Documents/Projetos/Python/SoftgranResizerVM/Resizer
> Linux/dist/resizer_linux
>
> ----------------------------------END----------------------------------------
>
> It compile fine, no problem with modules or whatever. I can type
> ./resizer_linux and it open the app with no problems, the app works fine!
> Also, my executable already have the flag for executable permissions!
> It give-me no log erros... It just doesnt open with double click(No errors
> message, app working in terminal...)
>
> My Code:
> #!/usr/bin/env python3
> import os
> import sys
> from pathlib import Path
> clear = lambda: os.system('clear')
>
> if sys.version_info[0] < 3:
> print("Por favor utilize a versao mais recente de python!")
> exit()
> else:
> # Python3
> import tkinter as tk
> from tkinter import filedialog
> pass
>
> def automatico_manual():
> clear()
> print("BEM VINDO!! Por favor, leia os avisos!")
> print("\nAviso 1: Este aplicativo serve para alterar o tamanho total
> da sua maquina virtual, e esta versao é funcional apenas para: \n- Linux
> Debian ou Derivados\n- Imagem VDI")
> print("\nAviso 2: Apos alterar para um tamanho a maquina virtual, ela
> nao pode mais ser 'diminuida', por isso tenha cuidado!\n EX: Se voce
> colocar 100 GB na VM, depois nao conseguira colocar 50GB, os valores
> validos serao apenas >= 100\n")
> automatico_ou_manual = input("Voce quer selecionar manualmente o local
> da sua .vdi ou ela esta na pasta padrao de VMS?\n1 - Manualmente\n2 -
> Automatico(Padrao, deve ser usado de preferencia)\n\nSua escolha: ")
> if automatico_ou_manual == '1':
> clear()
> print("Entrando no modo manual....")
> root = tk.Tk()
> root.withdraw()
> print("Por favor, selecione o caminho onde esta sua .VDI do
> virtualbox")
> caminho_da_vdi = filedialog.askopenfilename()
> print("Caminho da VDI:", caminho_da_vdi)
> perguntas(caminho_da_vdi)
> else:
> prucura_pastas_virtualbox()
>
> def prucura_pastas_virtualbox(): #Procura o diretorio do Virtual Box
> clear()
> print("Metodo automatico iniciado...")
> home = str(Path.home())
> caminho_pasta_virtualbox_linux = home + "/VirtualBox VMs/" #Caminho
> das VMS
> print("\nEstou navegando agora no diretorio: ",
> caminho_pasta_virtualbox_linux)
> print("Abaixo estao as pastas das suas maquinas virtuais, os nomes sao
> iguais aos que aparecem no aplicativo do Virtual Box: \n")
> dicionario_da_pasta = [] #Cria o dicionario
> i = 0 #Contador das pastas
> for pastas in os.listdir(caminho_pasta_virtualbox_linux):
> i += 1 #soma mais 1 ao contador
> pasta_com_barra = pastas + "/"
> dicionario_da_pasta.insert(i, pasta_com_barra)
> print(i, " - ", pastas)
>
> numero_da_vm = input("\nDigite o ID da VM que deseja alterar o
> tamanho\nEX: 3\nSua escolha: ")
> contador_de_vm_INT = int(numero_da_vm) - 1
> #dicionario_da_pasta[diretorio_da_vm] EH O NOME DA PASTA SELECIONADA
> diretorio_da_vm = caminho_pasta_virtualbox_linux +
> dicionario_da_pasta[contador_de_vm_INT] #algo semelhante a
> /home/mrminetoons/VirtualBox VMs/win7VM
> print(diretorio_da_vm)
> procura_vdi(diretorio_da_vm)
>
> def procura_vdi(diretorio_da_vm): #Procura a .vdi dentro do diretorio do
> Virtual Box
> clear()
> os.chdir(diretorio_da_vm)
> for entry in os.listdir(diretorio_da_vm): #Lista tudo dentro do
> diretorio
> if entry.endswith('.vdi'): #Filtra apenas as .vdi do
> diretorio listado
> clear()
> print("Caminho escolhido: ", diretorio_da_vm)
> print("VDI Encontrada: ",entry)
> perguntas(entry) #Chama o Questionario
> else:
> print("\nNao pude encontrar sua .vdi nesta pasta! Verifique se
> esta na pasta correta!")
> exit()
>
> def perguntas(nome_da_vdi): #Pergunta quantidade de GB que vai usar
> tamanho_da_vdi = input("\nAviso: O valor aqui se refere ao tamanho
> TOTAL da sua maquina virtual!\nDigite o tamanho da sua maquina virtual em
> GB\nEX: 100\nTamanho desejado: ")
> tamanho_vdi_GB = int(tamanho_da_vdi) * 1024
> resizer(nome_da_vdi, tamanho_vdi_GB, tamanho_da_vdi)
>
> def resizer(nome_da_vdi, tamanho_vdi_GB, tamanho_da_vdi): #Faz o
> trabalho de alterar o valor de GB da VDI
> clear()
> print("Nome da VM selecionada: ", nome_da_vdi)
> print("Novo Tamanho a ser alocado na VM:", tamanho_da_vdi, "GB")
> resposta = input("\nVoce tem certeza que deseja realizar esta
> operacao(S/N)?\n")
> if resposta.lower() == "s":
> print("\n")
> string_oq_fazer = 'VBoxManage modifyhd "{0}" --resize
> {1}'.format(nome_da_vdi, tamanho_vdi_GB)
> os.system(string_oq_fazer)
> print("\nCaso a mensagem acima seja uma porcentagem de 0% -> 100%
> significa que deu tudo certo!\nCaso contrario o Virtual Box retornou o erro
> acima! ")
> print("\nPorem voce ainda nao terminou! No seu windows, procure
> pela ferramente chamada 'Criar e Formatar Particoes do Disco
> Rigido'\nClique no disco C com o botao direito e selecione 'Estender
> Volume' entao clique em Avancar.\nPronto! :)")
> input("Finalizando... Pressione qualquer botao para sair...")
> exit()
> else:
> print("Voce cancelou a operacao, saindo...")
> exit()
>
> if __name__ == "__main__":
> automatico_manual()
> else:
> automatico_manual()
>
> ----------------------------------------------------------------------------END--------------------------------------------------------------------
> Is it any problem with 'if __name__ == "__main__":
> automatico_manual()
> else:
> automatico_manual()'
> ?
>
> My Linux: Debian GNU/Linux bullseye/sid
> My Python Version: 3.8.6
> My PyInstaller Version: 4.0
> My GNOME Version: 3.38.1
>
> If I generate the app in Windows, and open the executable, it works fine,
> open with double click!
>
> I appreciate any help!! Please!! Thanks!! :D
>
--
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyinstaller/f1b1631d-220b-4581-86d8-78c37835bca2n%40googlegroups.com.