Bottom Page

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.
Quote
#2
You can use the likes of pyinstaller and cx_freeze.
Quote
#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.
Mekire likes this post
Feel like you're not getting the answers you want? Checkout the help/rules for things like what to include/not include in a post, how to use code tags, how to ask smart questions, and more.

Pro-tip - there's an inverse correlation between the number of lines of code posted and my enthusiasm for helping with a question :)
Quote
#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
Quote
#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).
Feel like you're not getting the answers you want? Checkout the help/rules for things like what to include/not include in a post, how to use code tags, how to ask smart questions, and more.

Pro-tip - there's an inverse correlation between the number of lines of code posted and my enthusiasm for helping with a question :)
Quote
#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...
micseydel likes this post
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
Quote
#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
Quote
#8
For most packages, you can go to PyPi,

look up the package and read the docs.
Quote
#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.
Quote
#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.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  autostart python scripts in background (Windows10) john36 4 399 Oct-01-2019, 01:36 PM
Last Post: john36
  In Visual Studio Python is not properly installed jalea148 4 242 Sep-26-2019, 12:31 PM
Last Post: snippsat
  Run macros of excel sheet from python scripts shubhamjainj 3 2,056 May-01-2019, 08:40 AM
Last Post: buran
  Python can't find module installed in anaconda iFunKtion 12 30,316 Mar-06-2019, 05:15 PM
Last Post: jwsmallz
  can same time have installed Python 3.7.2 64-bit ??? lsepolis123 5 700 Jan-17-2019, 11:29 AM
Last Post: snippsat
  Avoid hard-coded folderPath in the code (let users provide it) SunOffice024 6 744 Sep-08-2018, 06:41 PM
Last Post: SunOffice024
  Possible to run Python scripts from oracle? dglass 8 1,667 Sep-06-2018, 05:14 PM
Last Post: dglass
  Keyboard Maestro has problem importing python scripts bobsmith76 3 783 Aug-29-2018, 08:10 PM
Last Post: bobsmith76
  Python on Windows 2012RC2 (with VS Code 1.22.2). Scripts not generating output. JGFMK 2 915 Apr-24-2018, 08:17 PM
Last Post: JGFMK
  running two python scripts pythonper 1 830 Mar-14-2018, 06:57 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)