pyinstaller exe file opens up with errors by immediately closing how to resolve(debug) - cmd

exe file opens up then immediately closes. I even do not know what to share here or to see myself what is error giving.
I used code below in cmd
pyinstaller -F --add-data "./urls.csv;./" amzn_lilly4.1.1.py --onefile --clean --add-binary "./driver/chromedriver.exe;./driver"
and this are packages i import inside script
from tkinter import *
from tkinter import simpledialog
import pandas as pd
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver import DesiredCapabilities
import time

Related

flow_from_directory cannot find path error in Spyder

I saw a lot of questions about the subject here but unfortunately didn't find one that solved my problem.I have the following code:
import numpy as np
from numpy import asarray
from PIL import Image
import tensorflow as tf
import keras
from keras.preprocessing.image import ImageDataGenerator
datagen =ImageDataGenerator()
train_it = datagen.flow_from_directory("C:/Users/agns1/Downloads/by_class.zip/by_class/4a/hsf_1", class_mode='binary', batch_size=10)
the data is from MNIST data set . and the error is :
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:/Users/agns1/Downloads/by_class.zip/by_class/4a/hsf_1'
unfortunately, I cant seem to understand what is is the problem is it because of the zip ? Thank you:)

ModuleNotFoundError: No module named 'milvus'

Goal: to run this Auto Labelling Notebook on AWS SageMaker Jupyter Labs.
Kernels tried: conda_pytorch_p36, conda_python3, conda_amazonei_mxnet_p27.
! pip install farm-haystack -q
# Install the latest master of Haystack
!pip install grpcio-tools==1.34.1 -q
!pip install git+https://github.com/deepset-ai/haystack.git -q
!wget --no-check-certificate https://dl.xpdfreader.com/xpdf-tools-linux-4.03.tar.gz
!tar -xvf xpdf-tools-linux-4.03.tar.gz && sudo cp xpdf-tools-linux-4.03/bin64/pdftotext /usr/local/bin
!pip install git+https://github.com/deepset-ai/haystack.git -q
# Here are the imports we need
from haystack.document_stores.elasticsearch import ElasticsearchDocumentStore
from haystack.nodes import PreProcessor, TransformersDocumentClassifier, FARMReader, ElasticsearchRetriever
from haystack.schema import Document
from haystack.utils import convert_files_to_dicts, fetch_archive_from_http, print_answers
Traceback:
02/02/2022 10:36:29 - INFO - faiss.loader - Loading faiss with AVX2 support.
02/02/2022 10:36:29 - INFO - faiss.loader - Could not load library with AVX2 support due to:
ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'",)
02/02/2022 10:36:29 - INFO - faiss.loader - Loading faiss.
02/02/2022 10:36:29 - INFO - faiss.loader - Successfully loaded faiss.
02/02/2022 10:36:33 - INFO - farm.modeling.prediction_head - Better speed can be achieved with apex installed from https://www.github.com/nvidia/apex .
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-4-6ff421127e9c> in <module>
1 # Here are the imports we need
----> 2 from haystack.document_stores.elasticsearch import ElasticsearchDocumentStore
3 from haystack.nodes import PreProcessor, TransformersDocumentClassifier, FARMReader, ElasticsearchRetriever
4 from haystack.schema import Document
5 from haystack.utils import convert_files_to_dicts, fetch_archive_from_http, print_answers
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/haystack/__init__.py in <module>
3 import pandas as pd
4 from haystack.schema import Document, Label, MultiLabel, BaseComponent
----> 5 from haystack.finder import Finder
6 from haystack.pipeline import Pipeline
7
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/haystack/finder.py in <module>
6 from collections import defaultdict
7
----> 8 from haystack.reader.base import BaseReader
9 from haystack.retriever.base import BaseRetriever
10 from haystack import MultiLabel
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/haystack/reader/__init__.py in <module>
----> 1 from haystack.reader.farm import FARMReader
2 from haystack.reader.transformers import TransformersReader
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/haystack/reader/farm.py in <module>
22
23 from haystack import Document
---> 24 from haystack.document_store.base import BaseDocumentStore
25 from haystack.reader.base import BaseReader
26
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/haystack/document_store/__init__.py in <module>
2 from haystack.document_store.faiss import FAISSDocumentStore
3 from haystack.document_store.memory import InMemoryDocumentStore
----> 4 from haystack.document_store.milvus import MilvusDocumentStore
5 from haystack.document_store.sql import SQLDocumentStore
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/haystack/document_store/milvus.py in <module>
5 import numpy as np
6
----> 7 from milvus import IndexType, MetricType, Milvus, Status
8 from scipy.special import expit
9 from tqdm import tqdm
ModuleNotFoundError: No module named 'milvus'
pip install milvus
import milvus
Traceback:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-91c33e248077> in <module>
----> 1 import milvus
ModuleNotFoundError: No module named 'milvus'
I was facing the same problem and I got around it by simply uninstalling pymilvus and reinstalling the older version.
pip list showed pymilvus v2.0.0
pip uninstall pymilvus removed the current version
pip install pymilvus==1.1.2 installed the older version and voilĂ ;
IT WORKS PEACEFULLY
I would recommend to downgrade your milvus version to a version before the 2.0 release just a week ago. Here is a discussion on that topic: https://github.com/deepset-ai/haystack/issues/2081

cannot import name 'BlobServiceClient' even if 'Azure-blob-Storage' latest version azure-storage-blob==12.9.0 is installed

I am trying to execute a script in 'Azure Notebooks' to upload blob to Azure Data lake Gen 2 using 'Azure-storage-blob', but couldn't as I am unable to import 'BlobServiceClient'. I have latest version of 'Azure-storage-blob' - 12.9.0 installed. But still facing issue in importing 'BlobServiceClient'
Below is the code
import azure.storage.blob
from azure.storage.blob import blockblobservice
import os, uuid
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient, __version__
Below is the error
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-278-283cd1817c6e> in <module>
7 from azure.storage.blob import blockblobservice
8 import os, uuid
----> 9 from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient, __version__
10
11 try:
ImportError: cannot import name 'BlobServiceClient'
Try with this
1. Uninstall azure-storage-blob using: pip uninstall azure-storage-blob.
2. Reinstall azure-storage-blob using: pip install azure-storage-blob.
And from your code from azure.storage.blob import blockblobservice you are trying to import blockblobservice . In newer versions of azure-storage-blob the import BlockBlobService has been renamed to BlobServiceClient.
I tried with this import statement
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient, __version__
OUTPUT:
For more details refer this document

cx_Freeze encodings for creating macOS application

I am trying to create a standalone Python3 macOS application including tkinter and selenium by using cx_Freeze. There are three files in my project:
tkinter_tab3.py (contains GUI)
user.txt (contains user info)
ver004.py (called from tkinter_tab3.py and executes tasks)
I created the following setup.py file with tkinter_tab3.py being the file to be turned into the executable:
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = ['encodings'], excludes = [])
includefiles = ['user.txt', 'ver004.py']
import sys
base = 'Win32GUI' if sys.platform=='win32' else None
executables = [
Executable('tkinter_tab3.py', base=base, targetName = 'suprbotcho')
]
setup(name='suprbotcho',
version = '1.0',
description = 'test',
options = dict(build_exe = buildOptions),
executables = executables)
However, when I run $python3 setup.py build then click on the created executable, I receive this error back in the terminal:
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
In addition, when I run $python3 setup.py bdist.mac and $python3 setup.py bdist.dmg, I receive the following error:
build/suprbotcho-1.0.app/Contents/MacOS/lib/numpy/core/lib/libnpymath.a(npy_math.o):
error: can't copy 'build/suprbotcho-1.0.app/Contents/MacOS/lib/numpy/core/lib/libnpymath.a(npy_math.o):': doesn't exist or not a regular file
I do not understand where I am going wrong because I have read other posts about the encodings problem however I found no progress after trying out the posted solutions.
Here are the imports for each python file:
tkinter_tab3.py
from tkinter import *
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import numpy as np
import time
from datetime import datetime
from threading import Timer
from ver004 import SuPrBoTcHo, InIt_UsEr
ver004.py
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import numpy as np
import time
from datetime import datetime
from threading import Timer
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import NoSuchElementException
If I could get help on fixing this particular problem, that would be great. If you have any particular questions, feel free to let me know.
(python version: 3.6.3)
I had the same problem.
The solution was to upgrade cxfreeze to the latest version, i.e do the following steps-
pip install -U cx_Freeze==6.0.b1

iolib import error in python

On Mac OS X Mountain Lion, I try
import numpy as np
import os
import statsmodels.api as sm
I get this error:
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /Users/idf/PycharmProjects/PyAlgoTrade/GoldvsMiners.py
Traceback (most recent call last):
File "/Users/idf/PycharmProjects/PyAlgoTrade/GoldvsMiners.py", line 9, in <module>
import statsmodels.api as sm
File "/Library/Python/2.7/site-packages/statsmodels-0.0.0-py2.7-macosx-10.8-intel.egg/statsmodels/api.py", line 1, in <module>
import iolib, datasets, tools
ImportError: No module named iolib
If I add
import sys
print("=======")
print sys.path
print("=======")
I get
=======
['/Users/idf/PycharmProjects/PyAlgoTrade', '/Library/Python/2.7/site-packages/pytz-2013b-py2.7.egg', '/Library/Python/2.7/site-packages/statsmodels-0.0.0-py2.7-macosx-10.8-intel.egg', '/Library/Python/2.7/site-packages/pip-1.4-py2.7.egg', '/Users/idf/PycharmProjects/PyAlgoTrade', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages']
=======
I have tried searching the net, but I am stuck on this one. Any ideas?

Resources