Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 pyinstaller
#1
hi guys,

i want to convert a file - try5.py - into a - try5.exe

when i use pyinstaller in the terminal - it only creates a file called try5.spec, and a sub-directory called 'build' where within it a directory called try5 and within it a .zip file called base_library.zip

but nowhere to be found a try5.exe

you have an idea how to fix this ?

thanks
Quote
#2
.exe shall be in dist folder.
Here i run,and i use cmder.
# File used,<more> in cmd
C:\code
λ cat hello.py
# hello.py
print('hello world')
input('Press Enter to exit')

# Make
C:\code
λ pyinstaller --onefile hello.py
140 INFO: PyInstaller: 3.4
140 INFO: Python: 3.7.3
141 INFO: Platform: Windows-10-10.0.18362-SP0
142 INFO: wrote C:\code\hello.spec
276 INFO: UPX is not available.
278 INFO: Extending PYTHONPATH with paths
['C:\\code', 'C:\\code']
278 INFO: checking Analysis
345 INFO: checking PYZ
386 INFO: checking PKG
397 INFO: Bootloader c:\python37\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
397 INFO: checking EXE

# cd to dist
C:\code
λ cd dist

# List files,<dir> i cmd
C:\code\dist
λ ls
hello.exe*

# Run .exe
C:\code\dist
λ hello
hello world
Press Enter to exit

C:\code\dist
Quote
#3
there is no such folder under the dist directory, there is only 'hello world' folder there, from a previous conversion (which i think succeeded, but i don't remember how it succeeded back then).

and by the way, it's under linux terminal which i try to run it
Quote
#4
(May-23-2020, 02:40 PM)astral_travel Wrote: and by the way, it's under linux terminal which i try to run it
The dist folder should be there,but it it dos not create .exe under Linux,just hello which can be executed.
# File used
root@kali-tom:~/Documents# cat hello.py
# hello.py
print('hello world')
input('Press Enter to exit')

# Make
root@kali-tom:~/Documents# pyinstaller --onefile hello.py
39 INFO: PyInstaller: 3.6
39 INFO: Python: 3.7.5
40 INFO: Platform: Linux-5.3.0-kali2-amd64-x86_64-with-debian-kali-rolling
40 INFO: wrote /root/Documents/hello.spec
43 INFO: UPX is available.
44 INFO: Extending PYTHONPATH with paths
['/root/Documents', '/root/Documents']
45 INFO: checking Analysis
49 INFO: checking PYZ
51 INFO: checking PKG
52 INFO: Bootloader /usr/local/lib/python3.7/dist-packages/PyInstaller/bootloader/Linux-64bit/run
52 INFO: checking EXE

# cd to dist
root@kali-tom:~/Documents# cd dist

# List files
root@kali-tom:~/Documents/dist# ls
hello

# Run
root@kali-tom:~/Documents/dist# ./hello
hello world
Press Enter to exit

root@kali-tom:~/Documents/dist#
Quote
#5
okay, so when i move the file onto windows (in another computer) - how can i run it there ? will it show it as .exe ?

the whole purpose of this is to run the program under windows (probably in cmd)

this is the output of when i try to run it:

Output:
tal@tal-HP-Notebook:~/Documents/python_folder$ pyinstaller --onefile try5.py 48 INFO: PyInstaller: 3.6 48 INFO: Python: 3.7.2 49 INFO: Platform: Linux-4.4.0-178-generic-x86_64-with-debian-stretch-sid 50 INFO: wrote /home/tal/Documents/python_folder/try5.spec 52 INFO: UPX is not available. 53 INFO: Extending PYTHONPATH with paths ['/home/tal/Documents/python_folder', '/home/tal/Documents/python_folder'] 54 INFO: checking Analysis 54 INFO: Building Analysis because Analysis-00.toc is non existent 54 INFO: Initializing module dependency graph... 56 INFO: Caching module graph hooks... 61 INFO: Analyzing base_library.zip ... 4007 INFO: Caching module dependency graph... 4143 INFO: running Analysis Analysis-00.toc 4158 INFO: Analyzing /home/tal/Documents/python_folder/try5.py 4161 INFO: Processing module hooks... 4161 INFO: Loading module hook "hook-xml.py"... 4452 INFO: Loading module hook "hook-pydoc.py"... 4452 INFO: Loading module hook "hook-encodings.py"... 4525 INFO: Looking for ctypes DLLs 4526 INFO: Analyzing run-time hooks ... 4533 INFO: Looking for dynamic libraries 4957 INFO: Looking for eggs 4958 INFO: Python library not in binary dependencies. Doing additional searching... Traceback (most recent call last): File "/home/tal/.local/bin/pyinstaller", line 8, in <module> sys.exit(run()) File "/home/tal/.local/lib/python3.7/site-packages/PyInstaller/__main__.py", line 114, in run run_build(pyi_config, spec_file, **vars(args)) File "/home/tal/.local/lib/python3.7/site-packages/PyInstaller/__main__.py", line 65, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "/home/tal/.local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 734, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "/home/tal/.local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 681, in build exec(code, spec_namespace) File "/home/tal/Documents/python_folder/try5.spec", line 17, in <module> noarchive=False) File "/home/tal/.local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 244, in __init__ self.__postinit__() File "/home/tal/.local/lib/python3.7/site-packages/PyInstaller/building/datastruct.py", line 160, in __postinit__ self.assemble() File "/home/tal/.local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 478, in assemble self._check_python_library(self.binaries) File "/home/tal/.local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 568, in _check_python_library python_lib = bindepend.get_python_library_path() File "/home/tal/.local/lib/python3.7/site-packages/PyInstaller/depend/bindepend.py", line 945, in get_python_library_path raise IOError(msg) OSError: Python library not found: libpython3.7.so.1.0, libpython3.7mu.so.1.0, libpython3.7m.so, libpython3.7m.so.1.0 This would mean your Python installation doesn't come with proper library files. This usually happens by missing development package, or unsuitable build parameters of Python installation. * On Debian/Ubuntu, you would need to install Python development packages * apt-get install python3-dev * apt-get install python-dev * If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin) tal@tal-HP-Notebook:~/Documents/python_folder$
Quote
#6
The Python version you use now is missing some libraries that Pyinstaller need.
Can try this as a fix without having to rebuild.
sudo apt-get install libpython3.7-dev
pyinstaller Wrote:PyInstaller is tested against Windows, Mac OS X, and GNU/Linux. However,
it is not a cross-compiler: to make a Windows app you run PyInstaller in Windows;
to make a GNU/Linux app you run it in GNU/Linux, etc.
So need to build on each platform.
So now the have build hello.py on two platforms.
Could make it like this so it use right executable on OS it's on.
import platform
import subprocess

if platform.system() == 'Windows':
    subprocess.run('hello.exe')
elif platform.system() == 'Linux':
    subprocess.run('./hello')
else:
    print('Mac')
Quote
#7
okay, got it

thank you for the response

ah, but regarding using pyinstaller,
when i try to install the packages it gives me the following output:

Output:
tal@tal-HP-Notebook:~/Documents/python_folder/dist/hello_world$ sudo apt-get install libpython3.7-dev [sudo] password for tal: Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package libpython3.7-dev E: Couldn't find any package by glob 'libpython3.7-dev' E: Couldn't find any package by regex 'libpython3.7-dev' tal@tal-HP-Notebook:~/Documents/python_folder/dist/hello_world$
Quote
#8
Try update first look at Install libpython3.7-dev.
Quote
#9
okay, the first command did did some work, but the second one i copied and paste gave me the same ouput
Quote
#10
The problem for you is that when they build Python on this Distro they did not include Python shared library.
Python library not found: libpython3.7.so.1.0, libpython3.7mu.so.1.0, libpython3.7m.so, libpython3.7m.so.1.0
Try:
sudo apt-get install python3-dev
If that not work you most search for solution,there are several suggestion out there.

I use pyenv Simple Python Version Management when need to install a new Python version or switch.
So also here most include shared library's.
Let say i want to use Python 3.8.3 and use pyinstaller.
# Install with --enable-shared
tom@tom-VirtualBox:~$ PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.8.3
Downloading Python-3.8.3.tar.xz...
-> https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tar.xz
Installing Python-3.8.3...
Installed Python-3.8.3 to /home/tom/.pyenv/versions/3.8.3

# Set as system wide version
tom@tom-VirtualBox:~$ pyenv global 3.8.3

# Install pyinstaller
tom@tom-VirtualBox:~$ pip install pyinstaller

# Make
tom@tom-VirtualBox:~$ pyinstaller --onefile hello.py
61 INFO: PyInstaller: 3.6
61 INFO: Python: 3.8.3
66 INFO: Platform: Linux-4.15.0-32-generic-x86_64-with-glibc2.2.5
67 INFO: wrote /home/tom/hello.spec
.....
17781 INFO: Appending archive to ELF section in EXE /home/tom/dist/hello
17832 INFO: Building EXE from EXE-00.toc completed successfully.

# Cd to dist and run
tom@tom-VirtualBox:~$ cd dist

tom@tom-VirtualBox:~/dist$ ls
hello

tom@tom-VirtualBox:~/dist$ ./hello
hello world
Press Entert to quit
You can of course also do it as shown over if you setup pyenv Wink
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)