Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to run Pyinstaller executable on Linux

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

like image 873
Piyush Shrivastava Avatar asked Sep 12 '17 13:09

Piyush Shrivastava


People also ask

Does PyInstaller work on Linux?

The user can run the packaged app without installing a Python interpreter or any modules. PyInstaller supports Python 3.7 and newer, and correctly bundles many major Python packages such as numpy, matplotlib, PyQt, wxPython, and others. PyInstaller is tested against Windows, MacOS X, and Linux.

Why is PyInstaller exe not working?

The most common reason a PyInstaller package fails is that PyInstaller failed to bundle a required file. Such missing files fall into a few categories: Hidden or missing imports: Sometimes PyInstaller can't detect the import of a package or library, typically because it is imported dynamically.

Do you need Python to run a PyInstaller exe?

They do not need to have Python installed at all. The output of PyInstaller is specific to the active operating system and the active version of Python. This means that to prepare a distribution for: a different OS.


2 Answers

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

like image 200
Piyush Shrivastava Avatar answered Nov 03 '22 00:11

Piyush Shrivastava


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...

like image 28
lenivaya10001 Avatar answered Nov 03 '22 02:11

lenivaya10001