Run portable python without console?

1,418 views
Skip to first unread message

xbtsw Chen

unread,
Apr 4, 2013, 2:18:20 PM4/4/13
to portabl...@googlegroups.com
Hi,

Is there anyway I can run portable python without the console window presented?

Like following:
Python-Portable.exe main.py

I found invoking the App\pythonw.exe doesn't work because the pythonw.exe will then refer to the libs in local python installation rather than portable python installation.

Thanks!

Best,
xbtsw


Perica Zivkovic

unread,
Apr 11, 2013, 1:23:28 PM4/11/13
to portabl...@googlegroups.com
Good idea, at the moment this is not possible I will try to include command line switch in the next version for this.

Perica Zivkovic

unread,
May 15, 2013, 4:50:46 PM5/15/13
to portabl...@googlegroups.com
I have just released 2.7.4.1 and this version includes additional launcher that is using pythonw - running Python code without console window.

Use PythonW-Portable.exe

Hernan Berguan

unread,
Nov 6, 2013, 11:13:30 AM11/6/13
to portabl...@googlegroups.com
Hi,

I've got Portable Python installed on a network unit. I've tried two versions (2.7.5.1 and 3.2.5.1), default/full installation both of them. I do need to get rid of the console, so I'm executing scripts with "App\pythonw.exe mystuff.py". It doesn't always work. For example, when I try to use NTEventHandler for logging I'm getting the following error message:
    The Python Win32 extensions for NT (service, event logging) appear not to be available.

So, I'd need to use this PythonW-Portable.exe launcher, but I can't find it: I've got IDLE-Portable.exe, IPython-Portable.exe, Python-Portable.exe and QtDesigner-Portable.exe, but no PythonW-Portable.exe.

Am I missing something?

Perica Zivkovic

unread,
Nov 6, 2013, 1:25:25 PM11/6/13
to portabl...@googlegroups.com
Interesting, this should be included in the default installation. Can you do full install on the local system and see does it make difference ?

Hernan Berguan

unread,
Nov 8, 2013, 7:39:58 AM11/8/13
to portabl...@googlegroups.com
I've done a clean default (full) instalation both network an locally. I can't see any differences.

With this naming convention:
    C: -> local unit
    I: -> network unit
    X: -> C: or I:  (both of them)
    py27 -> folder for the 2.7.5.1 installation
    py32 -> folder for the 3.2.5.1 installation
What I've got is:
    - In X:\py27:
        · Glade3-Portable.exe
        · IDLE-Portable.exe
        · IPython-Portable.exe
        · PyScripter-Portable.exe
        · Python-Portable.exe
        · PythonW-Portable.exe
        · QtDesigner-Portable.exe
    - In X:\py32:
        · IDLE-Portable.exe
        · IPython-Portable.exe
        · PyScripter-Portable.exe
        · Python-Portable.exe
        · QtDesigner-Portable.exe

And I've run the following tests:
    X:\py27\PythonW-Portable.exe I:\myscript.py
    X:\py27\App\PythonW.exe I:\myscript.py
    X:\py27\Python-Portable.exe I:\myscript.py
    X:\py27\App\python.exe I:\myscript.py
    X:\py32\App\PythonW.exe I:\myscript.py
    X:\py32\Python-Portable.exe I:\myscript.py
    X:\py32\App\python.exe I:\myscript.py

... with different results, being py32\Python-Portable.exe the only one completely successful (the only one successful in logging with NTEventHandler).

As you thought, PythonW-Portable.exe did exist in py27, which I only use for testing purposes. I apologize for the mistake. Anyway, it seems that it's missing in the py32, which is the one I'd prefer to have in production.
By the way, could you give me any guidance about how to know the differences between Python and PythonW versions? I mean something further than "with or without console", something that I could understand their different behaviours with. (I didn't found it in the documentation and I'm new in this group.)

Thanks in advance

Perica Zivkovic

unread,
Nov 8, 2013, 2:18:31 PM11/8/13
to portabl...@googlegroups.com
Only difference is that PythonW.exe suppresses the terminal (command) window, see official docs:

http://docs.python.org/2/using/windows.html

"This suppresses the terminal window on startup."

Perica Zivkovic

unread,
Nov 8, 2013, 2:19:28 PM11/8/13
to portabl...@googlegroups.com
difference between *-Portable.exe and native Python.exe executables is that portable shortcuts also set python environment variables before running the scripts.

Hernan Berguan

unread,
Nov 11, 2013, 3:58:17 AM11/11/13
to portabl...@googlegroups.com
If this is the only difference, I can't understand why the same script works when is executed with Python-Portable but it doesn't when executed with PythonW-Portable.

Perica Zivkovic

unread,
Nov 11, 2013, 4:24:18 AM11/11/13
to portabl...@googlegroups.com
Could you attach the (example) script so that I can try to reproduce the problem?

Hernan Berguan

unread,
Nov 11, 2013, 5:21:42 AM11/11/13
to portabl...@googlegroups.com
import logging
import logging.handlers

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
ntl = logging.handlers.NTEventLogHandler("Testing Python")
logger.addHandler(ntl)

data = "Hello World!"
logger.info(data)

Works fine when executed with py32\Python-Portable.exe but not when executed with py32\App\PythonW.exe  (I can't try py32\PythonW-Portable.exe because it's missing).
I suppose it has something to do with the environment variables set by the launchers or something else than makes the win32 extensions unavailable, but I have no idea of what to set or how to avoid this problem.

Perica Zivkovic

unread,
Nov 11, 2013, 2:59:53 PM11/11/13
to portabl...@googlegroups.com
Try to open command prompt and set environment variables PATH and PYTHONPATH to the folder where python.exe is. E.g. if your portable python is in E:\PortablePython\App

then first do 

SET PATH=%PATH%;E:\PortablePython\App

then 

SET PYTHONPATH=E:\PortablePython\App

and then try to run the script with py32\App\PythonW.exe

These are the two env variables set by the shortcuts
Reply all
Reply to author
Forward
0 new messages