PyQt5 file missing (PyQt noob) - python

I have a study assignment due that requires me to convert a *.ui file from Qt into a *.py file using the command prompt.
However I have been struggling because I can not find the Pyuic5/4 module used to convert a *.ui file into a *.py file.
{I have literally dug through and searched for it in my drive and can not find it}
I have the mots recent Qt and Python download and running well.
Any help or alternative method to converting *.ui to *.py would really be appreciated!

Try to run pip install pyuic5-tool in your terminal.

Related

Can I compile a python script to an executable file, so that cannot be reversed back to the source code?

I want to create a python .exe file in order to sell it to a client, however I'm worried that python can easily be reversed and the source code can be found, rendering my work less valuable for the future. Is there any way I can compile python code and make it irreversible?
Any other suggestions to go about solving this issue are welcomed.
you can also install auto_py_to_exe with pip, call it in your terminal to open it, just select your .py file and itll convert it to an .exe for you

Main Python File Using Another Python File (I Want To Convert To .exe)

I Created a Program That Has 2 .py files.
I Want To Make The Program a .exe file, I do it using cx_Freeze.
My Problem Is That I Convert The main.py To .exe but The Second Python File Is Still a .py File.
I Don't Want It Be a .py Because If It Is The User Can See The Code.
If I Also Convert The Second Python File The Program Doesn't Work Because I import The Python File In The Main File.
Any Suggestions?
(I Don't Want To Copy The Second Python File To The Main Python File)
You are chasing the wrong rabbit here. The various tools that generate executable files from Python code are not compilers. They are just tools that embed a Python interpretor with py (or pyc) files to allow users to use the program without a prior Python installation.
Said differently you should not use them to hide your code (except from people not knowing a lot of Python): a pyc does not contain text code but according to the answers to Is it possible to decompile a compiled .pyc file into a .py file? , tools exists that convert back a pyc file into a py file (of course except the comments).
IMHO, you should better google for python obfuscate to find tools dedicated to obfuscation, what neither cx-freeze nor pyinstaller are.
BTW while there are appropriate use cases for obfuscation you should be aware that a determinate attacker can always circumvent it. The reason why the real protection for intellectual property is law and not technics...
I'm not sure how two or more .py files can be converted to .exe.
But in python the easiest way to convert to .exe is a module named pyinstaller .
You can install it using command pip install pyinstaller can get it . After just go to the directory where your project files are and open command prompt in that directory and execute pyinstaller file_name

Python file converrted to .exe says has files and modules

I have used several tools (pyinstaller, cx_Freeze, py2exe) to convert my .py file to .exe file. But with each one of these, the resultant .exe file closes as soon as it runs. Here is a screenshot of the exe file created form pyinstaller.
I have looked at several answers on SO and other platforms but haven't been able to find a solution. Any help would be greatly appreciated.
My apologies for not being able to type these traccebacks out here as I had to take a quick screenshot as the window closed in a second.
The .py file runs fine on its own; there's no issue with the code.
I had this problem about a year ago with pyinstaller and this 2 methods helped me:
Adding import pkg_resources.py2_warn to my script
Using --onedir instead of --onefile
You can also do it using cmd:
pip install pyinstaller
cd followed by the location where your Python script is stored
so an example is:
cd C:\Users\Ron\Desktop\MyPython
then:
pyinstaller --onefile pythonScriptName.py
instead of pythonscriptname.py, put in your python file name.
When you do this there should be a new file called dist in your directory. Wait for a few mins and there should be an .exe file in there.
Here's a temporay solution: I removed all imports related to the googleapiclient for google docs. The .py file gets compiled properly after that.
More Context: There seems to be some issue in this particular library library that causes issues. I have tested the given solutions, they don't seem to work for me. I'll update this answer if I find a "permanent" solution.

Pyinstaller / auto-py-to-exe additional files

I have a python script that uses the face_recognition library(as well as other libraries), and want to make an .exe file out of it. I use pyinstaller, but I get the following error when trying to run the .exe file:
I guess it needs a hook or something, but I am not really familiar with how to write one or what the contents of it should be. I had a similar problem in the past with another python script I was trying to make into an .exe file, and luckily someone knew how to help me out. It would be great if someone could guide me through this.
Since the exe is complaining about a missing module "pkg_resources.py2_warn2 add --hidden-import=pkg_resources.py2_warn to your build command
To complete the job you should read https://github.com/ageitgey/face_recognition/issues/357
If you're trying to make an .exe file with libarys, I would recommend using https://pypi.org/project/auto-py-to-exe/ auto-py-to-exe, i've used it many times and it works great.
I had the same error.
I fixed this by adding the required libraries to the python environment that auto-py-to-exe or pyinstaller uses

How to convert python .py file into an executable file for use cross platform?

I've been searching through SO for a while now trying to come up with an answer to this but due to my inexperience with programming I don't understand much of the documentation, nor am I confident enough to experiment too much.
Would anyone be able to describe in slightly simpler terms how I would use programs like Py2exe, PyInstaller, cx_freeze etc.? I just want a way for others (mainly friends) to be able to run my (simple, text only) program without having to download python themselves. If there is an easier way to do this I'd appreciate knowing that too.
Running Vista 32bit, python 2.7
There are two distinct ways of freezing python scripts to create executables:
Packing the interpreter and *.pyc files into one exe file-container. Such an approach is used by tools like PyInstaller, Py2exe, cx_freeze.
Creating native code from Python source, usually using a middle step of converting Python-source to C or C++ code. This is done by such tools as Shed-skin and Nuitka. The problem of this aproach is that such tools do not always support all the functionality of Python (e.g. they can have some typing limitations and so on)
The point where you have to start is reading the documentation. Such tools are not just push-and-run style tools, they usually have some configuration that must be implemented (that's the problem of possibly all build systems, and as the project grows, the configuration and number of hooks also grows).
You can start with Py2exe tutorial and 'hello-world' to get acquainted with that how compilation is done. As far as I know it's a simplest way to get your goal.
And the last thing, you can't create cross-platform native executables as their file formats are strongly operating system and hardware dependent.
Download py2exe
Download this msvcp90.dll
Copy your FileCode.py AND msvcp90.dll to C:\Python27\
In C:\Python27\ create new text file, then enter this code inside it:
from distutils.core import setup
import py2exe
setup(console=['Avril.py'])
Replace Avril.py with YourFileName.py
Save the file as setup.txt
Open CMD and type this:
cd C:\Python27\
python setup.txt py2exe
Now go to C:\Python27\dist\ and there's your .exe program.
Source: Manvir Singh
Python scripts can be made directly executable, like shell scripts, by putting the python environment path in the top of the script file.
#!/usr/bin/env python3.5
The Python installer automatically associates .py files with python.exe so that a double-click on a Python file will run it as a script. The extension can also be .pyw, in that case, the console window that normally appears is suppressed.
Detailed description also for linux is here.
Install pyinstaller, a program that converts .py to .exe for python 2.7 to where python is located:
cd C:\python27\scripts
pip install pyinstaller
then move whatever python file you want to compile to C:\python27\scripts, compile from there by using:
pyinstaller --onefile yourfile.py
the --onefile is optional but it packages the whole thing(in this example yourfile.py) into one .exe. Once everything is done there will be 2 new folders along with a .spec file. From C:\python27\scripts open the folder dist. Your .exe will be located there in one file which you can double tap to execute and distribute to anyone who doesn't have python. Hope it helps.

Categories

Resources