Execute pytest via pyinstaller created exe extension file - python

I had made more than 1 pytest test files I needed it to be convert them to a single exe file
I used pyinstaller for that not able to convert the test cases to .exe file
Even though if some how I will convert it I could not run it via clicking on .exe file as on console I am running it by python -m pytest
So Please help me guys

Create a bat file rather, if you want to run it on a windows environment.
Keep the required libraries ( like pytest, selenium.. etc) in a requirements.txt file in root directory.
Keep the bat file with the root directory.
The commands in the bat file will go as below.
cd path/to/current/directory &
virtualenv env &
"cmd.exe" "\c .env/Scripts/Activte && pip install -r
requirements.txt && pytes your commands to trigger script
here"
Once you hit the bat the dependent Libraries will be installed and later your scripts will trigger

Is there any way to execute the exe file created by pyinstaller, that like on just clicking the exe file the exe will get execute based on the code mentioned just like on clicking the exe file the code should execute via python -m pytest

Related

How can I run the file created with pyinstaller in ubuntu terminal?

On Windows, I can convert my python code to exe file using pyinstaller. And by running the resulting exe file, I can get the same output as in the normal code. In order to do the same on Ubuntu, I created the file with pyinstaller on Ubuntu again. But I couldn't find how to run this resulting file. Can you help with this?
For example:
After using pyinstaller on Windows, the file was created as:
example.py → example.exe
After using pyinstaller on Ubuntu, the file was created as:
example.py → example
But here I could not run the example file in any way.
In your terminal cd into the directory containing the executable. It should be in a dist/ folder.
Then run ./example If that doesn't work it just means that the execution bit isn't set on the file.
chmod +x ./example
./example

Creating exe from a Python Directory

so I finished a project in python and now I wanna transfer the whole project into exe.
I have a couple directories in the project which makes it look like so :
My Main is in ServerStart and it has dependencies from all the other files in the directories.
how can I create 1 exe file that will run it all?
I tried using pyinstaller and failed miserable.
the command I used(already inside the projects directory)
pip install pyinstaller
cd ServerStart
pyinstaller --onefile ServerMain.py
Am I missing on something ? it just creates an exe that on click -and closes immediately , when I used pause in the batch , it seemed like the program didn't even start running .
python script
Try using auto-py-to-exe. I have used it once and it seemed to work fine for me.

Sending a PyCharm project to someone

I just finished working on a PyCharm project (using python 3.7), which uses libraries downloaded using PyCharm's built in functionality. I just want to send this project to my boss so that he can simply run it by clicking on it, without having to go through downloading PyCharm and downloading the applicable packages. Please tell me that there is a way to do this. Thank you
if you want to convert your python project to a program exucutable in windows you can use the library pyinstaller.
install the library:
pip install pyinstaller
then in the path of the project,open a command console and type the following commands.
if you want the executable in one file(slower start):
pyinstaller.exe --onefile --windowed --icon="your_icon_file".ico "your_python_script".py
if you want the executable in one folder(faster start):
pyinstaller.exe --onedir --windowed --icon="your_icon_file".ico "your_python_script".py
this wil create a folder call "dist" where your .exe will be,
pd: whith the --onedir command you will see all your dependencies in that folder, if you have a simple script you can use the first option.
Link to the pyinstaller documentation:https://pypi.org/project/pyinstaller/
You could solve this issue by converting the .py file to an executable file or .exe file....
Hopefully it helped..thx
A simple way to that would be sharing it on github with a requirements.txt file containing all the dependencies which then can be installed using python -m pip install -r requirements.txt.
Or You can use pyinstaller --onefile <yourfile.py> to create a .exe file which could be run without any requirements on windows.

How to convert python script to exe Without additional files

I want to convert my python script to exe without additional files like ddl, pyd..
Is it possible?
Use pyinstaller https://github.com/pyinstaller/pyinstaller
Install it by running pip install pyinstaller in terminal / console
Then run pyinstaller --onefile yourscriptsname.py and it will create you an exe file in the same directory

Bash script equivalent in windows to run pip and python commands?

I have a python code which I need to send it to a client who will run it windows.
The python code works on a few imported modules mentioned in requirements.txt:
requests==2.11.1
xlwt==1.1.2
beautifulsoup4==4.5.1
If I have to execute the code in windows, I’ll have manually ask the client to download these above modules before running the script.
I have created a bash script ( for linux), which is such:
sudo pip install -r requirements.txt
echo "Requirements met"
python ./isb.py
What is the bash script equivalent in windows? I want to client to only execute 1 file which executes other remaining files.
Can an executable be made for a task like this?
The code and other files are here if need be.
I has similar task in the past. So I just used a tool py2exe which builds a standalone executable and it resolves dependencies at build time. A valid python interpreter will be included to the build. So your client can just execute this standalone exe file by double-click or from cmd shell.

Categories