Python Forum
How to provide python scripts to someone without python installed
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to provide python scripts to someone without python installed
#1
so I've recently learned some basic python knowledge,and tried to send the file to someone without python installed,and he was unable to open it. i was confused as why would python be a thing without the ability to open the script you create?
its like opening a shop in real life but having no doors.

i was sure python was pretty popular,but why can't it be opened on its own? or is there an easy way of converting it into an .exe?

if not,whats the point of python? to be used only for personal use? theres no way.

anyway,please reply.
Reply
#2
You can use the likes of pyinstaller and cx_freeze.
Reply
#3
If you Google "python to exe" there are tools for making it more convenient for the recipient. That said, they can always download Python, just like they almost certainly downloaded Java to run Java programs.

Also, Python tends to come pre-installed on Linux and OS X, although Windows (which uses .exe) does indeed have this hurdle.
Reply
#4
Python is an interpretive language. A statement is compiled as it is encountered, the compiler (and interrupter) are separate from the script,
but the script is dependent on them to run.

Other languages that are interpreted include Java which is actually a hybrid, it's first compiled into byte code that must be run by JVM
Lisp, Pike, Ruby and Forth are others.

Interpretive languages can be run as the code is entered, making them ideal for development.

Compiled languages like C, C++, Fortran or Pascal must first be compiled, so development is a cycle of write code, compile, test, but when
done, you have an executable program that will run on it's own.

There are scripts that bundle other scripts and interpreter together so they can be run without having an installed interpreter installed,
Pyinstaller is one of these
Reply
#5
(Dec-15-2016, 07:32 PM)Larz60+ Wrote: Other languages that are interpreted include Java which is actually a hybrid
Python does this too, that's what .pyc files are, and some interpreters like PyPy even do JIT compilation.

For the op though, the solution to the problem regardless of all the interesting background is to send the interpreter along with the script (which is what the .exe converters do) or the recipient of the script also installs Python, just like they would Java (and to your point, Ruby, Perl or whatever else).
Reply
#6
(Dec-15-2016, 07:17 PM)jak123456 Wrote: i was sure python was pretty popular,but why can't it be opened on its own? or is there an easy way of converting it into an .exe?

if not,whats the point of python? to be used only for personal use? theres no way.

anyway,please reply.

See other posts for a technical answer. But remember that your .exe is of no use to OSX and Linux users... Universality is in the eye of the beholder...
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#7
Thanks for clearing things up guys,but i have no idea how to actually work with the programs you provided. for example py2 only works for older versions and cx freeze has a weird file type which means i don't know how to open it.

ill try again later in the afternoon but if anyone knows how to operate these it'll be great
Reply
#8
For most packages, you can go to PyPi,

look up the package and read the docs.
Reply
#9
(Dec-16-2016, 08:04 AM)jak123456 Wrote: cx freeze has a weird file type which means i don't know how to open it.
No cx_Freeze give as example an "exe" file.
The most updated for newer Python version are PyInstallercx_Freeze and pynsist 1.9.
Reply
#10
This is an example of using cx_freeze on the sample file SimpleTkApp.py and its setup.py provided with cxfreeze using python 3.
  • The sample folder is located at C:\Python34\Lib\site-packages\cx_Freeze\samples\Tkinter.
  • Open a command prompt and enter > cd /d C:\Python34\Lib\site-packages\cx_Freeze\samples\Tkinter
  • The previous line sets the working directory to C:\Python34\Lib\site-packages\cx_Freeze\samples\Tkinter.
  • Enter > py -3 setup.py install
  • The .exe will be created and located in folder C:\Python34\Lib\site-packages\cx_Freeze\samples\Tkinter\build\exe.win32-3.4
  • Double click the SimpleTkApp.exe located in the folder in the previous line to test it worked.

To do this on your own file copy the setup.py file to the location of your py file, alter the setup.py to suit your .py file ie change 'SimpleTkApp.py' to your .py name
executables = [
    Executable('SimpleTkApp.py', base=base)
]
Follow the above substituting the file path to your .py folder.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Launcher (on Windows) only necessary when 2 or more Python versions installed? pstein 1 265 Feb-17-2024, 12:43 PM
Last Post: deanhystad
  Trying to us python.exe from our network to run scripts cubangt 3 817 Aug-17-2023, 07:53 PM
Last Post: deanhystad
  output provide the filename along with the input file processed. arjunaram 1 903 Apr-13-2023, 08:15 PM
Last Post: menator01
  Randomizer script to provide options based on user and priority cubangt 10 2,331 Mar-11-2022, 07:22 PM
Last Post: cubangt
  Installed versions of Python SamHobbs 5 2,460 Sep-02-2021, 02:28 PM
Last Post: jefsummers
  Running python scripts from github etc pacmyc 7 3,609 Mar-03-2021, 10:26 PM
Last Post: pacmyc
  I seem to have two versions of python 3.7.9 installed miner_tom 7 4,351 Nov-22-2020, 06:42 PM
Last Post: miner_tom
  Reading SQL scripts from excel file and run it using python saravanatn 2 2,459 Aug-23-2020, 04:49 PM
Last Post: saravanatn
  No Scripts File present after python installation ag2207 5 4,766 Jul-30-2020, 11:11 AM
Last Post: buran
  Package installed through Anaconda "not found" by Python zonova 0 2,256 May-08-2020, 11:50 PM
Last Post: zonova

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020