Is it possible to use pyWin32 without installing it?
I would like to include it into python's interpreter folder.
I have managed to use Python interpreter without installing it (simply installing it and copy&pasting installed directory into my product).
I need also the same with pyWin32.
My objective is:
Client receives a folder with a script (batch) which will run python program in a console. The client does not have to install python, pywin32, nothing. What he needs is to copy and paste my product and run the console-based program.
Is it possible?
My objective is: Client receives a folder with a script (batch) which
will run python program in a console. The client does not have to
install python, pywin32, nothing. What he needs is to copy and paste
my product and run the console-based program.
I would suggest something along the lines of using pyinstaller or any other python code to executable converter.
http://www.pyinstaller.org/
PyInstaller is a program that freezes (packages) Python programs into
stand-alone executables, under Windows, Linux, Mac OS X, FreeBSD,
Solaris and AIX. Its main advantages over similar tools are that
PyInstaller works with Python 2.7 and 3.3—3.5, it builds smaller
executables thanks to transparent compression, it is fully
multi-platform, and use the OS support to load the dynamic libraries,
thus ensuring full compatibility.
To me it seems this would suit your/your clients needs quite well. Furthermore pyinstaller is easy to use.
Related
I am trying to convert one single c file into an executable with pyinstaller. Now the reason why I want to compile with pyinstaller is because of the fact, that the exe file is supposed to be run on both a mac as well as a windows machine.
Now, how can this be done?
You can include Cython/C modules in a Pyinstaller executable.
However, Pyinstaller is not suitable for your goal of making a single executable that works on Mac and Windows. From the first question of the Pyinstaller FAQs:
Can I use PyInstaller as a cross-compiler?
Can I package Windows binaries while running under OS X?
No, this is not supported. [...]
It seems like you've fundamentally misunderstood what Pyinstaller does: it packages a Python script with Python and its libraries to allow you to use the Python script without having to install Python separately. To do this though it needs to package a version of Python specific to the platform, and so the executable will only work on the same operating system that it was created on.
In addition, it deals with compiled libraries (like Cython modules) by zipping them up and the extracting them into a temporary folder when run. Therefore, even if Pyinstaller somehow managed to bundle two versions of Python to work on both Windows and Mac your C compiled module would still only be compiled for a single platform, so by doing it they way you describe you've actually made your code less portable.
I don't believe there are any obvious tools to do what you're asking.
I'm writing what is a relatively small desktop application, but I'm using several technologies/languages and not sure the best way to create a installer script.
I have a python script which uses tornado and scapy (which also requires pcapy), and have a kernel extension that needs to be installed.
This python script is executed and works in conjunction with a node-webkit (nw) app I'm writing. Any suggestions on the easiest way to ensure all of the dependencies are met, and properly installed without the user having to touch the command line? Using python setuptools or pyinstaller? Package it together with nw? Use OS X packagemaker? Writing a bash script? Should I distribute these dependancies with my actual app?
Are you using python2 or python3? Dependencies for scapy differ.
I need to package my Python application, its dependencies, and Python itself into a single MSI installer for distribution to users. The end result should desirably be:
Python is installed in the standard location
the package and its dependencies are installed in a separate directory (possibly site-packages)
the installation directory should contain the Python uncompressed and a standalone executable is not required
Kind of a dup of this question about how to make a python into an executable.
It boils down to:
py2exe on windows, Freeze on Linux, and
py2app on Mac.
I use PyInstaller (the svn version) to create a stand-alone version of my program that includes Python and all the dependencies. It takes a little fiddling to get it to work right and include everything (as does py2exe and other similar programs, see this question), but then it works very well.
You then need to create an installer. NSIS Works great for that and is free, but it creates .exe files not .msi. If .msi is not necessary, I highly recommend it. Otherwise check out the answers to this question for other options.
My company uses the free InnoSetup tool. It is a moderately complex program that has tons of flexibility for building installers for windows. I believe that it creates .exe and not .msi files, however. InnoSetup is not python specific but we have created an installer for one of our products that installs python along with dependencies to locations specified by the user at install time.
I've had much better results with dependencies and custom folder structures using pyinstaller, and it lets you find and specify hidden imports and hooks for larger dependencies like numpy and scipy. Also a PITA, though.
py2exe will make windows executables with python bundled in.
py2exe is the best way to do this. It's a bit of a PITA to use, but the end result works very well.
Ok, I have used py2exe before and it works perfectly except for one thing... It only works on executable windows machines. I then learned about Jython which turn a python script into a .Jar file. Which as you know is executable from any machine that has Java ("To your latest running version") installed. Which is great because both unix, windows, and ios (Most of the time) Run java. That means its executable from all of the following machines. As long as they run Java. No need for "py2mac + py2exe + freeze" just to run on all operating systems. Just Jython
For more information on how it works and how you can use it click here.
http://www.jython.org/
I'm making a program in python, but once I'm finished with the program, will the users have to download the python environment in order to use my program, or will it work without the python environment once compiled? Also, will it automatically be cross-platform or will I have to download a conversion program to make it work for Linux, Mac OS and Windows? I'm new to the language so this is confusing me.
Many Linux systems come with Python installed already. However, there are some tools to help if it is not:
pyinstaller for Windows, Linux, and Mac OS X (does not work for Python 3)
bbfreeze for Windows and Linux
py2exe for Windows
Freeze for Linux
py2app for Mac OS X
Have a look at py2exe for windows, linux and mac is likely to have it preinstalled.
They would need a python interpreter to use your program unless you turn your python script into a windows executable. One way of doing that is by using Py2exe
It depends on what 3rd party libraries you include in your program.
For example I never managed to make a windows executable with the PyQt lib,
by using py2exe. But this was 2-3 years ago and things might have changed.
Also don't hardcode paths in your program and make use of functions like os.path.join
Don't make assumptions about config files and stuff. Do check on runtime the platform
your program is running on and act accordingly.
In general, your biggest problem will be the Windows platform.
I need to run a Python script on a machine that doesn't have Python installed. I use Python as a part of a software package, and Python runs behind the curtain without the user's notice of it.
What I did was as follows.
Copy python.exe, python26.dll, msvcr90.dll and Microsoft.VC90.CRT.manifest
Zip all the directory in LIBs directory as the python26.zip
Copy all the necessary dll/pyd files inside the DLL directory.
It seems to work, but when I change the python26.zip to the other name such as pythonlib.zip, it cannot find the Python library any more.
Question 1: What's the magic behind the python26.zip name? Python automatically finds a library inside a python26.zip, but not with different name?
Question 2: If I have python26.zip at the same directory where python.exe/python26.dll is, I don't need to add path sys.path.append (THE PATH TO python26.zip). Is it correct?
Python has built-in libraries, and sys is one of them. I thought that I could use sys.path to point to whatever Python library in the ZIP file I needed. But, surprisingly, if I use the library name as Python26.zip, it just worked. Why is this so?
I have been using PortablePython for a year now, and I find it great as it is working on my locked-down work-notebook.
There is a Python 2.5.4, 2.6.1 and a 3.0.1 version.
From Sylvain Pointeau's blog:
The procedure is actually very simple, just download the msi installer from
http://www.python.org/getit/ and type the command:
C:\development\apps>msiexec /a python-3.3.2.msi /qb
TARGETDIR=C:\development\apps\python33
His example uses msiexec (aka MSI Administrative Installer for you UniExtract people) to force an extract to TARGETDIR. You'll notice that there is an internal installer which you delete.
EDIT: Also you can make it silent as well, but doing this every time you want to use python seems dumb. Just extract to a tempdir and then cleanup when they uninstall it.
PS: I didn't see how old this was! :D
I looked into the Python interpreter source code, and I did some experiments. And I found that the Python interpreter prepend the "THE DIRECTORY OF PYTHONXXX.DLL + pythonXXX.zip" no matter what. XXX is the version of the Python interpreter.
As a result, if there is a python26.zip in the same directory as the python26.dll. I could use all of the Python library automatically.
Another option is installing WinPython. It uses an installer, but it doesn't require admin rights (tested on Windows 7). Unlike Portable Python, it even has a Python 3.3.5 version.
py2exe will allow you to compile your Python script into a Windows executable. It may or may not work better than PortablePython, but perhaps it could be a little cleaner with regard to the number of files you need to distribute for your "behind the curtain" program.
Another option might be to consider PyInstaller which will create stand-alone Python applications cross-platform. From the home page:
PyInstaller is a program that converts (packages) Python programs into stand-alone executables, under Windows, Linux, and Mac OS X. [...] The main goal of PyInstaller is to be compatible with 3rd-party packages out-of-the-box. This means that, with PyInstaller, all the required tricks to make external packages work are already integrated within PyInstaller itself so that there is no user intervention required. You'll never be required to look for tricks in wikis and apply custom modification to your files or your setup scripts. As an example, libraries like PyQt and Matplotlib are fully supported, without having to handle plugins or external data files manually. Check our compatibility list of SupportedPackages.