Problems with pyinstaller doesn´t show all things that I created - python-3.x

I've been working on an app to manage a little store with Python and SQLite. For GUI I used tkinter. I've written 13 Python scripts to make the app work. One of them call "principal.py" which imports most of the scripts and the other scripts import other modules like tkcalendar or xlwt (to write excel sheets), etc...
This is an example from "principal.py" first lines of code
#===========IMPORTAR PAQUETES=============
import sqlite3
from sqlite3 import Error
import os
import sys
import tkinter as tk
from tkinter import ttk
from tkinter import *
from tkinter import scrolledtext
from tkinter import Menu
from tkinter import messagebox as msg
import tkcalendar
from tkcalendar import *
import conexion as cnx
import proveedores
from proveedores import Proveedores
from proveedores import *
import productos
from productos import Categoria_Productos
from productos import *
import clientes
from clientes import Clientes
from clientes import *
import colaboradores
from colaboradores import Colaboradores
from colaboradores import *
import herramientas
from herramientas import Roles
from herramientas import Usuarios
from herramientas import *
import recepciondoc
from recepciondoc import Recepcion
from recepciondoc import *
import ventas
from ventas import Ventas
from ventas import *
import ingresos
from ingresos import *
import movimientos
from movimientos import *
import excel_ingresos
from excel_ingresos import *
import excel_venta
from excel_venta import *
This is how my files are structured and how it works when I run the script from vscode
But when I tried to make an exe from my little project using PyInstaller, it looks incomplete like this:
this is how it looks like when I run the exe file from the "dist" folder
I worked like this
Create the spec file with pyi-makespec principal.py
Re-write the principal.spec to save the database path
pyinstaller --windowed principal.spec

Related

AWS --extra-py-files throwing ModuleNotFoundError: No module named 'pg8000'

I am trying to use pg8000 in my Glue Script, following are params in Glue Job
--extra-py-files s3://mybucket/pg8000libs.zip //NOTE: my zip contains __init__.py
Some Insights towards code
import sys
import os
from awsglue.transforms import *
from awsglue.utils import getResolvedOptions
from pyspark.context import SparkContext
from awsglue.context import GlueContext
from awsglue.job import Job
import boto3
from pyspark.sql import Row
from datetime import datetime, date
zip_path = os.path.join('/tmp', 'pg8000libs.zip')
sys.path.insert(0, zip_path)
def dump_python_path():
print("python path:", sys.path)
for path in sys.path:
if os.path.isdir(path):
print(f"dir: {path}")
print("\t" + str(os.listdir(path)))
print(path)
print(os.listdir('/tmp'))
dump_python_path()
# Import the library
import pg8000
Dump in cloudwatch
python path: ['/tmp/pg8000libs.zip', '/opt/amazon/bin', '/tmp/pg8000libs.zip', '/opt/amazon/spark/jars/spark-core_2.12-3.1.1-amzn-0.jar', '/opt/amazon/spark/python/lib/pyspark.zip', '/opt/amazon/spark/python/lib/py4j-0.10.9-src.zip', '/opt/amazon/lib/python3.6/site-packages', '/usr/lib64/python37.zip', '/usr/lib64/python3.7', '/usr/lib64/python3.7/lib-dynload', '/home/spark/.local/lib/python3.7/site-packages', '/usr/lib64/python3.7/site-packages', '/usr/lib/python3.7/site-packages']

how to import the libraries of toimage in scipy.misc?

import matplotlib.pyplot as plt
import cv2
from scipy.misc import toimage
im = toimage(skeleton)
cv2.imwrite('./zee/img'+(str(count)+".png"),im)
but we get
ImportError: cannot import name 'toimage'

How can I solve this problem in vs code, ipython (tensorflow)?

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import check_util.checker as checker
from IPython.display import clear_output
from PIL import Image
import os
import time
import re
from glob import glob
import shutil
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow import keras
print('tensorflow version: {}'.format(tf.__version__))
print('GPU available: {}'.format(tf.test.is_gpu_available()))
When I run this, there is no error. But it shows as indefinitely in progress.
(Current 630..631..632...sec)

Import sequences in Python 3.7

I want to organize a package with this structure:
/program.py
/__init__.py
/data/
/data/__init__.py
/data/method_1.py
/data/method_2.py
/data/classes.py
program imports method_1 and method_2, method_1 and method_2 import classes. But I get an error: ModuleNotFoundError: No module named 'method_1'. How should I organize this package and what should I write in init.py files?
program.py:
import __init__
from data import classes
from data import method_1
from data import method_2
...
__init__.py:
__all__ = ['data']
from data import *
/data/__init__.py:
__all__ = ['classes', 'method_1', 'method_2']
from method_1 import *
from method_2 import *
from classes import *
/data/method_1.py: (and also /data/method_2.py)
import classes
...
method_1, method_2, and classes are all in the data package, hence:
# data/__init__.py
from .method_1 import *
from .method_2 import *
from .classes import *
...
# data/method_1.py
from . import classes
Because the data package is in the same directory with program this should work:
#program.py
from .data import classes
from .data import method_1
from .data import method_2
# data/__init__.py
from .method_1 import *
from .method_2 import *
from .classes import *
#data/method_1.py
from . import classes
#data/method_2.py
from . import classes

Merging PyOpenGL with Tkinter

PyOpen GL with Tkinter
Hey guys how can I implement OpenGL into tkinter?
Should i use Pygame? But when I do so - only glClear(...) works.
I've heard about OpenGL.Tk but the problem is that when i want to import it, python gives me the following exception:
And here is my code I've written
import csv
from tkinter import *
import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.Tk import *
import os
from numpy import *
root = Tk()
canvas = Frame(root,width=500,height=500).pack()
os.environ['SDL_WINDOWID'] = str(canvas.winfo_id())
os.environ['SDL_VIDEODRIVER'] = 'windib'
pygame.init()
pygame.display.set_mode((500,500), OPENGL|DOUBLEBUF)
gluOrtho2D(-10,10,-10,10)
while True:
glClearColor(0.2,0.2,0.2,1)
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
glBegin(GL_POINTS)
glColor3f(1,1,1)
glVertex2f(0,0)
glEnd()
root.update()
pygame.display.flip()
pygame.time.wait(30)
Have you got any idea how can I make this working?
I've spent most of the time today to search for it...

Resources