How can I open another console window - rust

I am trying to open a new console terminal from Rust. With the help of documentation, I was capable of starting a terminal in the current terminal window, but not in another one.
For example, imagine I have one folder with two files main.py and bb.py and the following code does the thing I want
import os
os.system("start cmd /K python bb.py")
It opens a new terminal, and in this new terminal the command python bb.py is executed. How can I do this in Rust?

Related

.exe doesn't run after building from .py [duplicate]

This question already exists:
Can't run script when i convert .py to .exe [closed]
Closed 3 years ago.
I am beginner at python. I have just created a script which includes a Tkinter GUI application. Whenever i run it using cmd it works fine but whenever i tried to create an exe of it using pyinstaller or cx_Freeze it won't run. It just pops up console and terminates within a second.
I think your problem is that using cmd, it starts the program and does not terminate until you close the shell, and the tkinter window stays open, but when you use an exe file, it terminates after all the code is run once, so you should probably have a while loop running preferably forever until the window is closed by you.

Script that opens cmd from spyder

I am working on a text adventure with python and the issue i am having is getting spyder to open a interactive cmd window. so far i have tried os.systems('cmd / k') to try and open this which it did but i could not get any code to run and kept getting an app could not run this file error. my current code runs off a import module that pulls the actual adventure from another source code file. how can i make it to where only one file runs and opens the cmd window to play the text adventure?
(Spyder maintainer here) Cmd windows are hidden by default because there are some packages that open lot of them while running code (e.g. pyomo).
To change this behavior, you need to go to
Tools > Preferences > IPython console > Advanced settings > Windows adjustments
and deactivate the option called Hide command line output windows generated by the subprocess module.
I found myself in a similar situation, developing code for a research group with heavy Spyder usage. I came up with this workaround to force usage of the vanilla Popen class regardless of whether or not it is run from Spyder (full disclosure I have not tested it very aggressively):
import subprocess
try:
from spydercustomize import SubprocessPopen
except ImportError:
SubprocessPopen = subprocess.Popen
else:
SubprocessPopen = SubprocessPopen.__bases__[0]
process = SubprocessPopen()

Python3 GUI script does not work when double clicked

My GUI script that is a PyQt5 file (.pyw extension) does work when running on my IDE with a build configuration that tells the compiler to run the script with python3:
And it also works when i tell to the regular terminal on Linux to run same script with python3 like this:
When runned with the default python (python2.7) on a regular terminal it tells: ImportError: No module named PyQt5.QtWidgets.
My code does it have these lines on the start to tell that is a python3 script like: #!/usr/bin/python3 or #!/usr/bin/env python3 (I have python3 installed).
When double clicked on the Linux Mint File Explorer the cursor turns crosshair and nothing happends, with the terminal option, same happends and a empty terminal shows. Im talking these options
I guess Linux Mint still runs the scripts with python2.7 even when I added the bash lines to tell
Someone knows why the lines:
#!/usr/bin/python3
#!/usr/bin/env python3
doesnt work when just double click?
I want to run the script from the Linux File Explorer without the need of an IDE or using the terminal.
Try chmod +x file.py and run it in terminal by using ./file.py also try lunching the file from a different path, like python3 ~/path/to/file.py and see if the error persists

Is there a way we can change the working directory of Python (IDLE) permanently?

I am using Python Enthought Canopy. Each time I initiate the editor, I have to change the working directory by typing the code:
import os
os.chdir('C:/Users/Name/Canopy/scripts')
This is quite tedious as the directories are all reset after I quit the editor and start again.
Is there a way that I can change the default working directory, or change the profile of Canopy such that each time the settings will be run before coding?
1) Canopy's GUI is not IDLE.
2) Since this is ipython and has access to ipython magics, you can just type cd ~/Canopy/scripts with no import.
3) But I'm guessing that you have at least one script open in the editor. So you might prefer to just keep the directory synced to the editor, see http://docs.enthought.com/canopy/2.1/quick-start/code_editor.html#change-directory
4) All of the above said, yes you can run arbitrary code on ipython startup. See Ipython Notebook: Default Initialization Python Code

Create a New Command or Macro in Komodo 7.1 IDE to save and run a python file

How can I create a New Command or Macro in Komodo 7.1 IDE to save and run a python file?
I want the output to go to a New Console. Not the Command Output Tab.
If you put:
import code
code.interact(local=locals())
in your program, then you will be dumped to a python interpreter. (See Method to peek at a Python program running right now).
Use doCommand and runEncodedCommand to save and run the python file respectively:
komodo.assertMacroVersion(3);
if (komodo.view && komodo.view.scintilla) { komodo.view.scintilla.focus(); }
komodo.doCommand('cmd_save')
ko.run.runEncodedCommand(window, '/usr/local/bin/pythonw3 \"%F\" {\'cwd\': u\'%D\'}');

Resources