Jump to content

Compiling Python Scripts

iCantThinkOfAName

Hello,

Someone made me a python program, but never compiled it, I've googled around and don't particularly understand it very well, I can manage to compile a single script, but this has multiple scripts that are referred to from the main script, and I don't understand how to make this work.

EDIT: What I'm meaning is running it from a single executable.

Here's the link if you need to see: http://www.mediafire.com/file/z4rza1ym38luel5/SM64AutoSplitter-master_%25281%2529.zip/file

Thanks, Max

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Mira Yurizaki said:

If you're asking how to create a standalone Python app so you don't need a Python environment to run it: https://www.pyinstaller.org/

 

Otherwise, you don't typically compile Python scripts, you run them through an interpreter.

Yeah, thats what I meant, I don't really have a background in coding so compile seemed like the best thing to say. I did mess about with py installer, but don't understand how to add the dependency scripts.

Link to comment
Share on other sites

Link to post
Share on other sites

Python scripts are interpreted, not compiled. You need to download and install Python to run the script.

https://wiki.python.org/moin/BeginnersGuide/Download

 

EDIT: yes they can be compiled into C, I suppose

[Out-of-date] Want to learn how to make your own custom Windows 10 image?

 

Desktop: AMD R9 3900X | ASUS ROG Strix X570-F | Radeon RX 5700 XT | EVGA GTX 1080 SC | 32GB Trident Z Neo 3600MHz | 1TB 970 EVO | 256GB 840 EVO | 960GB Corsair Force LE | EVGA G2 850W | Phanteks P400S

Laptop: Intel M-5Y10c | Intel HD Graphics | 8GB RAM | 250GB Micron SSD | Asus UX305FA

Server 01: Intel Xeon D 1541 | ASRock Rack D1541D4I-2L2T | 32GB Hynix ECC DDR4 | 4x8TB Western Digital HDDs | 32TB Raw 16TB Usable

Server 02: Intel i7 7700K | Gigabye Z170N Gaming5 | 16GB Trident Z 3200MHz

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, 2FA said:

Python scripts are interpreted, not compiled. You need to download and install Python to run the script.

https://wiki.python.org/moin/BeginnersGuide/Download

 

EDIT: yes they can be compiled into C, I suppose

Yeah, I understand that they need to be ran through an interpreter, what I was trying to say in my OP is getting it to run from a single application without having to install all of the libraries.

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, iCantThinkOfAName said:

Yeah, thats what I meant, I don't really have a background in coding so compile seemed like the best thing to say. I did mess about with py installer, but don't understand how to add the dependency scripts.

if all you need is to run the script and you have python installed on your system you can use pip to download dependencies:

pip install --user <dependency>

if you don't want to or can't install python then pyinstaller is really the only way

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, iCantThinkOfAName said:

Yeah, thats what I meant, I don't really have a background in coding so compile seemed like the best thing to say. I did mess about with py installer, but don't understand how to add the dependency scripts.

It might do it automagically, assuming you have whatever dependencies you need installed on your environment.

 

EDIT: The documentation seems to imply this:

Quote

PyInstaller bundles a Python application and all its dependencies into a single package. The user can run the packaged app without installing a Python interpreter or any modules. PyInstaller supports Python 2.7 and Python 3.4+, and correctly bundles the major Python packages such as numpy, PyQt, Django, wxPython, and others.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Quote

It might do it automagically.

Pretty sure it doesn't, at least I think not having these scripts is what's causing the problem.

image.png.6d029f940c5e4cf5c64d1a6b2b60dd27.png

This is the error that I get, and read somewhere that it wasn't accessing some of the other scripts, could this mean something else?

https://pastebin.com/pa6ErKyT

Found this in one of the folders pyinstaller produced, I have all of these installed so I don't understand why that's happening

Link to comment
Share on other sites

Link to post
Share on other sites

23 minutes ago, Sauron said:

if all you need is to run the script and you have python installed on your system you can use pip to download dependencies:


pip install --user <dependency>

if you don't want to or can't install python then pyinstaller is really the only way

Alright, found a dependency that I didn't have, I go to install it through pip and it says it failed to build the wheel for it, how do I install a .whl file?

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, iCantThinkOfAName said:

Alright, found a dependency that I didn't have, I go to install it through pip and it says it failed to build the wheel for it, how do I install a .whl file?

what dependency is this?

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, iCantThinkOfAName said:

PyHook3

can you post the exact error message?

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

33 minutes ago, Sauron said:

you need to install swig

How do I do this? I've downloaded the windows version but don't understand how to install it

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, iCantThinkOfAName said:

How do I do this? I've downloaded the windows version but don't understand how to install it

there's an executable in the .zip, move it to a folder in your PATH or just have it in the folder you're running pip in.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Sauron said:

there's an executable in the .zip, move it to a folder in your PATH or just have it in the folder you're running pip in.

https://pastebin.com/bY9TLRai

Installed swig, but it didn't seem like it fully worked

 

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, iCantThinkOfAName said:

https://pastebin.com/bY9TLRai

Installed swig, but it didn't seem like it fully worked

 

try following this answer (make sure you choose the right python directory - you should have python36 or python37)

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

Python scripts are interpreted, not compiled. You just need to grab python from it's official website and then run it with python3 <your script file> from the command line. 

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

15 hours ago, Sauron said:

try following this answer (make sure you choose the right python directory - you should have python36 or python37)

Got it to install, with pyinstaller, do i need the modules installed that are in the script?

 

I followed that answer you sent me, but it still comes out with this.

https://pastebin.com/FybnnXSK

Link to comment
Share on other sites

Link to post
Share on other sites

On 6/8/2019 at 6:14 PM, Mira Yurizaki said:

If you're asking how to create a standalone Python app so you don't need a Python environment to run it: https://www.pyinstaller.org/

 

Otherwise, you don't typically compile Python scripts, you run them through an interpreter.

Or py2exe if you are on windows or py2app if you are on mac. Both are pretty easy to use. 
Here is tutorial http://www.py2exe.org/index.cgi/Tutorial

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×