Not able to run Pyinstaller executable on Linux - python

I am trying out pyinstaller for the first time. I created a file named hello.py with just one line of code:
print "hello"
I used the following command to make a binary:
pyinstaller hello.py
The process completed successfully and a binary was created at dist/hello. I am not able to run this binary file. When I tried to run it from the terminal, I got,
bash: .: hello: cannot execute binary file
I tried to double click it from nautilus but nothing is happening.
How can I run this binary file?
I am using Ubuntu 16.04

Got it running by typing the relative path dist/hello in terminal

for linux (tested on ubuntu 16.04 python3)
pyinstaller hello.py --onefile it create one file named hello.
Then go inside dist folder use terminal
cd dist.
Then
./hello.
Looks not as windows way , but work. ./hello is something like , run outside...

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

Pyinstaller executable can't run on other machines (OS X)

I am trying to package my python script (a script that asks for user input and runs solely in the Terminal window on mac). I package the application using 'pyinstaller' and the following code:
pyinstaller --oneapp my_script.py
This creates an executable in the dist folder in my targeted folder, and I can run the executable no problem. However when I try to send this application to my coworkers, the file is not recognized as an executable and opens in text editor. Trying to run the file from terminal on another computer will provide no result either.
If you specify only --onefile under Mac OS X, the output in dist is a UNIX executable myscript. It can be executed from a Terminal command line. Standard input and output work as normal through the Terminal window.
Have you tried executing it in terminal?
source: https://pyinstaller.readthedocs.io/en/v3.3.1/usage.html#building-mac-os-x-app-bundles

How do I run a Python 3.5 program that uses Tkinter on a computer without Python installed?

I have coded a program in Python 3.5 that uses the Tkinter import. I'm trying to figure out a way to run it on computers that don't have Python. First I tried freezing it but I haven't been able to because none of the freezing tools I found support Python 3.5. Then I tried possibly using a online idle but I couldn't find any that support Tkinter. I would prefer to be able to get a .exe file or something similar but if I could run it online that would be good too any ideas?
EDIT
So I have now successfully downloaded PyInstaller using pip. My current problem is when I type this into the console: pyinstaller.exe --onefile --windowed Finder.py
I get this error: 'pyinstaller.exe' is not recognized as an internal or external command,
operable program or batch file.
EDIT
I have now found the pathway to pyinstaller.exe. Now when I try to use it it says Access is denied.
I finally figured it out after about three days of work. Fist I downloaded PyInstaleller in the zipped form and extracted it. Then I put my program in the PyInstaller folder. Then I opened a regular command prompt. I then typed cd then the location of the PyInstaller folder. Finally I typed pyinstaller.py --one file --windowed program.py. Then when I went into the PyInstaller folder there was a folder called program with the .exe file in the dist folder. Thanks everyone for all of your help!
You can use pyinstaller to do that. I think its work fine on linux em linux.
Another option is use py2exe.
Try pyinstaller -F -w Finder.py as the command or you could check out CxFreeze.

Packages installed in anaconda but not in python

This is what I get after running the code on cmd:
conda info
I get:
conda version
3.19.3
conda build version
1.19.0
python version:
2.7.11.final.0
Now when I run the code on cmd:
python -V
I get:
python 2.7.11::anaconda 2.5.0(64 bit)
Now when I run a code in .ipynb it works fine, but when I run the code in a .py file it says:
no module named pandas.
What is the source of the problem?
Do I need to install the libraries again for running the .py file?
Anaconda creates a separate folder (C:/Anaconda). Python is installed to C:/Python27. If you are running IDLE (default Python editor) you will need to move it to C:/Anaconda. I suggest moving all the contents of C:/Python27 to C:/Anaconda, merging any common folders.
This answer assumes you are running a python file open in an editor. If this is not the case, try typing python filename.py into the command prompt instead of double-clicking the file.

Cannot get python on mac osx to reference my scripts folder

Am pretty new to python although have programmed a lot before. I'm using mac osx snow leopard and python 2.6.1.
I've followed this post about setting your PYTHONPATH to a custom scripts directory but can't get python to recognise it.
How can I run my python script from the terminal in Mac OS X without having to type the full path?
So i've got a simple helloworld script in /Users/richn/Documents/scripts/ called hello.py
Inside is this
#!/usr/bin/env python
print "Hello World!"
I've created a .profile file in my home directory with this in it
export PYTHONPATH=/Users/richn/Documents/scripts
I've also changed permissions of the file to make it executable with chmod a+x hello.py
Running ./hello.py in the terminal from that scripts folder works fine however whenever i run it outside of that folder i get this error
-bash: ./hello.py: No such file or directory
How can i get my scripts to run outside of that folder? Anyone got any ideas?
Thanks very much
What you'll want to do is to edit your PATH variable which is a list of directories your command shell checks when you run a command that does not begin with / or ./ rather than PYTHONPATH:
export PATH="$PATH:/Users/richn/Documents/scripts"
After you have exported your PATH variable you should be able to confirm that it has exported correctly:
echo $PATH
and afterwards you should be able to run "hello.py" successfully.

Categories