Creating .exe file from python package for windows10 - windows-10

I implemented one package with GUI based on Pyside2. This package has the following structure:
Repository
Function
GUI_class
Main_GUI.py
It means Main_GUI.py use some classes and function in GUI and Function folders. Now I want to create the executable version from it for windows 10. I tried Pyinstaller for this aim like the following comments:
(conda env)F:\Repository> Pyinstaller Main_GUI.py
But when I run the *.exe file in dist folder it gives me the following error:
ModuleNotFoundError: No module named 'pkg_resources.py2_warn'
Blockquote[15728] Failed to execute script pyi_rth_pkgre
Would you please help me how can I convert this python package to *.exe? Thank you in advance.
These are my version of my dependencies:
Python 3.6.10,
Pyinstaller 3.6,
Pyside2 5.13.2.

Related

how can i import win32com module in webcompiler (ide.goorm.io) in linux develop envilonment,

import error in webcomfiler Goorm Linux Envirenment.
I find python library directory and mv win32com folder.(https://sourceforge.net/projects/pywin32/)-unzipfile
and excute command_ python setup.py
but Just show error massage like this
Just download zipfileenter image description here
but when i excute installer file win32com in windows envirenment,there is no problem.
how can i solve this problem?
pywin32 is a package of extension modules for accessing Windows C and COM APIs in Windows Python.
You can't install it in Linux Python.

Unable to import sqlite3 using Anaconda Python

I am trying to do the following in Python 3.7.1 on Windows
import sqlite3
but I get the following error message
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "c:\programdata\anaconda3\lib\sqlite3\__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "c:\programdata\anaconda3\lib\sqlite3\dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: DLL load failed: The specified module could not be found.
I have searched for a solution to the problem for quite a while now to no avail. I have also successfully run pip install pysqlite3 on the Anaconda prompt, but the import still fails. What do?
I got this working on windows by downloading: the sqlite3 dll (find your system version)
And placing it into the folder: C:\Users\YOURUSER\Anaconda3\DLLs
(Depending on how you installed Anaconda, this may have to be placed into
the following folder: C:\ProgramData\Anaconda3\DLLs)
According to #alireza-taghdisian, you can locate the exact path of
your conda environments (where you need to copy the sqlite3 dll) by typing:
conda info --envs on your anaconda prompt.
Locate the sqlite3.dll file. In my case it was in following folder
C:\Users\Admin\anaconda3\Library\bin
where C:\Users\Admin\anaconda3 is the folder where Anaconda was installed
Add this to PATH in environment variables, and it should work then.
Try copying the sqlite3.dll from the
C:\Users\YOURUSER\anaconda3\Library\bin
folder to
C:\Users\YOURUSER\Anaconda3\DLLs
Please check https://github.com/jupyter/notebook/issues/4332
I added anaconda root/Library/bin to my PATH and now it works!
Add CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1 to your environment variables.
before executing the program, enter conda activate in your shell.
I had tried all above solutions But for me and my system I got to know that
I downloaded Python in C:\Python27 hence there is dll folder in python C:\Python27\DLLs
I installed Sqlite3.dll in my above dll folder
May be this solution will help you because it completely depends on where do you install your python
Happy coding :)
I put the sqlite3.dll in the path folder of my Python venv and still wont work. I suspected it is a path problem.
(In my case: E:\Virtual_Env\mini_zinc\env\Scripts)
I found in my case I messed up installation in a virtual evn, somehow using an anaconda python kernel within a Python venv.
I reinstall the Python Venv and check the python version after installed Env is correct (not the Anaconda python), then proceed with Jupyter Notebook (or Juyterlab) and works fine.
I was able to resolve this issue by putting sqlite3.dll file in the C:\Users<USERID>\AppData\Local\conda\conda\envs<ENV NAME>\DLLs.
Download sqlite3.dll file from https://www.sqlite.org/download.html
or copy it from C:\ProgramData\Anaconda3\DLLs\
I found the #elgsantos useful. But for those who are new to Python and Conda like me, I would like to add a little bit of details.
1- I use miniconda3 for creating new environment.
2- interestingly, I got two installation path on my computer for conda: the first one (the obvious) is located on "C:\Users\taghdisian\miniconda3". The second one is on "C:\Users\taghdisian\AppData\Local\r-miniconda". The latter is the primary path that you need to copy your sqlite3 files into the envs folder. I copy them in the "C:\Users\taghdisian\AppData\Local\r-miniconda\envs\sdr3.9\DLLs" in which the sdr3.9 is one of my virtual Condo environment.
you can locate the exact path of your conda environments (where you need to copy sqlite3) by typing the conda info --envs on your anaconda prompt.
I hope this help.
got the same error while loading the jupyter notebook from other conda prompt than "base" environment.
[1]: https://i.stack.imgur.com/2DW7E.png
Resolved by installing sqlite package
(nlpenv) C:\Users\arunk>conda install sqlite
launching
*
(nlpenv) C:\Users\arunk>jupyter notebook

how to install python library (Imported in our script file) automatically in windows 7

I have a script file named updatesCode.py
inside this file i am importing openpyxl,
i downloaded the tar file and extracted , went to setup.py file directory and ran python setup.py install because pip was not working in my case.
my question is : if i give my updatedCode.py to some one else, it will give error related to installation of the opepyxl library
Is there any way(like a script file that installs library) to insatll openpyxl library automatically before running updatedCode.py.
i tried to write a setup.py file but it didnt work. please give me suggestions to achieve this (how to specify dependencies in setup.py file )
updatedCode.py file has simple code to access a excel sheet, I am not creating a package.

How to change .py to .exe

I made a program in python which is in .py format. However, I would like it to be in .exe
The options I have found are:
py2exe
pyinstaller
The problems with those 2 are because I am running python 3.6 and those 2 programs do not support it, HELP!
Python 3.6 still isn't supported by Pyinstaller. So in order to use it you're gonna need Python 3.5 or below. So, you might wanna change your python version to 3.4 or 2.7. Then you can follow the procedure for creating the exe with pyinstaller. Also I think pyinstaller is a better option than py2exe.
However to make things work without switching to other versions, you might wanna try using cx_freeze:
1.Install the latest version of cx_freeze by pip install cx_Freeze.
2.Create a new python file named ‘setup.py’ on the current directory of your script.
3.On the setup.py, code this and save it:(here my prog.py refers to your .py file name)
from cx_Freeze import setup, Executable
base = None
executables = [Executable("my prog.py", base=base)]
packages = ["idna"]
options = {
'build_exe': {
'packages':packages,
},
}
setup(
name = "<any name>",
options = options,
version = "<any number>",
description = '<any description>',
executables = executables
)
4.With shift pressed right click on the same directory to open a command prompt window.
5.Type: python setup.py build.
6.Check the newly created folder ‘build‘. Within that folder you can able to find your application.
pyinstaller
pip install pyinstaller
Basic usage is very simple, just run it against your main script:
pyinstaller /path/to/yourscript.py
cx_Freeze
pip install cx-Freeze
auto-py-to-exe
pip install auto-py-to-exe
Then to run it, execute the following in the terminal:
auto-py-to-exe
With a simple google search, I found this question which gives a link to a version of py2exe which happens to support python 3.3 and up. Here is the link!
On that page you will find the following bit of information:
Py2exe is a distutils extension which allows to build standalone Windows executable programs (32-bit and 64-bit) from Python scripts; Python 3.3 and later are supported. It can build console executables, windows (GUI) executables, windows services, and DLL/EXE COM servers.
Notice:
Python 3.3 and later are supported.
I have created a batch file to do the work, but first, go to https://datatofish.com/add-python-to-windows-path/ and add python to your path.
Then create a new notepad file with this:
SET /P _input1= Enter the file directory:
cd %_input1%
SET /P _input2= Enter the file name:
pyinstaller --onefile %_input2%
ECHO The exe file is in the dict folder in %_input1%
pause
Save this as a .bat file anywhere and run it.
Enter the directory of the python script.
then the name.
Hope this helps!

Pyinstaller --onefile ImportError: No module named 'win32api'

Problem statement:
I can't seem to run
'PyInstaller --onefile myfile.py'
on a file containing
import wmi
It cannot find win32api. I get a popup warning saying python has stopped etc. My console says "ImportError: No module named 'win32api'". I can run 'import win32api', 'import win32com', and 'import WMI' in python directly in the same environment without issue. I fundamentally don't understand what is wrong here.
Error message:
3469 INFO: Loading module hook "hook-pywintypes.py"...
Fatal Python error: Py_Initialize: can't initialize sys standard streams
ImportError: No module named 'win32api'
I have tried:
PyInstaller - ImportError: No module named win32api - 'import os' works fine for PyInstaller and runs fine in python.
No module named 'win32api' - Not very helpful
How to install pywin32 module in windows 7 - This is where I got the SF link (python3.5 amd64 pywin32 version)
ImportError: no module named win32api -
I thought it might be a path thing, but my installation appears to be in the correct place: "C:\Users\myuser\AppData\Local\Continuum\Anaconda3\pkgs\pywin32-220-py35_2\Lib\site-packages\win32"
I can run 'PyInstaller --onefile myscript.py' on other files, and have without issue as long as they don't use the wmi module.
I looked at the win32com _init__.py line 5 where it's messing up and it's just an import statement for win32api.
System:
Windows 7 x64, Python 3.5.3 64bit, Anaconda 4.3.14 64bit, using pyinstaller 3.2.3 (recommended by this thread), with pywin32 220 (with sourceforge download [I know, I tried pip, conda, and easy_install]) and I'm running it in cmder as an admin.
In my case, I couldn't use the module in the python shell, even if original one could. When I execute python shell as an administrator option, it was solved. Try it with administrator execution. I used python version 3.5.2 with windows x64bits.
I face this problem but I install ---> pip install pypiwin32 to solve my problems

Resources