Python to exe with pyinstaller using anaconda is a huge file - python

When i do this imports and i create a exe file with pyinstaller. The dist folder is huge (+900Mbs). How can i reduce this?
import queue
import threading
import time
import dateutil.parser
import getpass
import json
import pandas as pd
import pickle
import pprint
import requests
import sys
import urllib3
import xlrd as xl
import xlwings as xw
import PySimpleGUI as sg
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from pathlib import Path
from openpyxl import load_workbook, cell
from pandas import ExcelWriter
from datetime import datetime, date
from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session

Related

Python: Import could not be resolved

These are the imports I am trying to import:
import json
import os
import re
import uuid
from google.auth.transport.requests import AuthorizedSession
from google.oauth2 import service_account
from google.auth import jwt, crypt
But I am getting this error:
Import "google.auth.transport.requests" could not be resolved Pylance(reportMissingImport)
Import "google.oauth2" could not be resolved Pylance(reportMissingImport)
Import "google.auth" could not be resolved Pylance(reportMissingImport)
Thanks for the answers in advance!

ImportError: cannot import name 'combined_rule_sentence_segmenter'

I'm facing error while importing "import en_ner_bc5cdr_md"
import scispacy
import spacy
from spacy import displacy
from collections import Counter
import en_core_web_sm
import en_ner_bc5cdr_md
import en_core_sci_sm
import en_core_sci_md
import en_ner_bionlp13cg_md
from scispacy.abbreviation import AbbreviationDetector
from scispacy.umls_linking import UmlsEntityLinker
from collections import OrderedDict
from pprint import pprint
Please help
You need to download the model first, try
!pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.5.1/en_ner_bc5cdr_md-0.5.1.tar.gz

ModuleNotFoundError: No module named 'Session'

When I run my python script file.py, I get an error ModuleNotFoundError: No module named 'Session'.
The imports on my script:
import os
import sys
import tensorflow as tf
import numpy as np
import random
import time
import requests
from requests import Request, Session
from flask_session import Session
from flask_session.__init__ import Session
import Session
from setup_inception import ImageNet, InceptionModel
You should not use from flask_session import Session
Instead use from flask_session.__init__ import Session
I'm sorry for the late answer, I have solved the problem with command:
import tensorflow.compat.v1 as tf
instead of
import tensorflow as tf
because I 'm using tensorflow 2.4

Question on importing library's into python3

I'm learning Python and the imports that have accumulated whilst developing my app seem like I'm repeating imports. Please can someone advise me on development practices.
from pathlib import Path
from urllib.request import urlopen
from gi.repository import Gtk, Gio
from gi.repository import GLib as glib
from gtk_assistant import AssistantApp
import urllib.request
import urllib.error
import xml.etree.ElementTree as ET
import json
import gi
import sys
import os
import hashlib
You can group imports like this if you want:
from urllib import request, error
from xml.etree import ElementTree as ET
import json, gi, sys, os, hashlib
However, the pep8 style guide says you should have them on seperate lines so the way you did it is fine

Pyinstaller dist file creates unused numpy pyd and dll files

I've used Pyinstaller to create an executable. The file is 80MB, 21 of which are from the numpy-atlas.dll file. However, my code does not use the numpy import.
It does have matplotlib.pyplot, but I was under the impression that only .pylab would contain numpy. Here are my imports.
I assume I am just being dense.
import os
import pickle
import tkinter as tk
import matplotlib.pyplot as plt
import pandas as pd
import periodictable as pt
import csv
from collections import OrderedDict

Categories