Open new powershell window in python - python

I am running a python script from powershell.
I'd like to open another powershell window from this python script so that the script can interact with this new powershell window.
subprocess.call('C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', shell=True)
is not openning a new window.
Thanks in advance!

Related

Why does PowerShell run in the background when I'm running a Python program?

I have created a Python program with a user interface and converted it to (exe) format.
And when I run the program, PowerShell opens in the background behind the program's interface.
How can I run the program without PowerShell appearing? Can it run in the background?
You should use pythonw.exe to run in the background.
If you already have the executable, try changing the extensions from .py to .pyw
See this similar question:
pythonw.exe or python.exe?

How to start python program with a terminal window on ubuntu startup

I want to start a python program on ubuntu startup and im using session and startup option for it. But each time the system boots python program starts but without a terminal window that I need. Is there any option to force program to start with terminal window?
To open a python application with a terminal window on startup just add it to the Settings >> Session and Startup with a following command gnome-terminal -- python3 path/to/app

Execute python script directly, shorcut and execute from startup

I did a application with Python 3 using Tkinter gui, on Raspbian with the RPi. I have three questions:
1) I've turned the python script into executable using:
chmod -x path/myfile.py
I've declared on the first line of script
#!/usr/bin/env python3
When I double click onthe script it pops up a windows asking if I want to execute normally or on the terminal. If i chose Execute, the script runs normally.
Is there any way to execute normally directly, without asking?
2) How do i create a shortcut on my Desktop to execute my python script?
I've created a file on the desktop and I edited the following:
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Name of the shortcut
Comment=Comment
Icon=path/pic.gif
Exec=python3 path/myfile.py
Terminal=false
The picture if the shortcut works, but the script it's not launched. It appears the hourglass and nothing happens.
3) How do I make a python script launch when at the startup of Raspbian?
I've already edited the
/etc/xdg/lxsession/LXDE/autostart
and also the
/etc/xdg/lxsession/LXDE-pi/autostart
with:
#python3 path/myfile.py
on the last line of the file. Rebooting the system, nothing happens.
Thank you for your help.

Hide Python console when running Tkinter script from shell command

I have extended the file context menu in the Windows registry and added a shortcut to a Python script (which is a Tkinter window). It runs fine, but obviously with the Python console in the background. I tried to change the shell command from python to pythonw (and renaming the file to .pyw) but then Windows always simply opens the "open with..." dialog and not the script. If I copy-paste the shell command and run it from cmd, it works. Running the .pyw from the explorer also works fine, without console.
Why is the behavior different when running it in the shell command?
This is in my .reg setup file under the command key:
#="pythonw \"C:\\test_script.pyw\" \"%1\""

Run python script in background

I have a python script that's run in the systray (WINDOWS), but when I use the pyinstaller2.0, it opens in systray, but also opens my console.
This script doesn't involve graphics, but I need it to run in background and preferably not open the console.
thanks in advance!

Categories