When running pygame in Ubuntu a terminal is opened along with the pygame window. I want to get rid of the terminal. I can launch pygame with nohup and &:
$ nohup python3 mygame.py &
This allows the terminal to be closed, but it does not prevent it from being opened in the first place.
Is there a way to run pygame without a terminal being opened?
The OP explains that one should create a desktop shortcut,
and the the terminal goes away.
Related
I'm trying to run python files in VSCode and I'm running into an issue after the program ends.
Ex. code:
# simple code
print(":(")
I have to type exit() every time I want to run code again, since the code finishes and the console shows >>> instead of the typical text (Computer name:Folder Username$).
Any thoughts? Thanks!
Details:
Extensions active: Python (Microsoft), Jupyter, Pylance
Edit: Running files with python3 myFile.py in terminal (the real mac one and the VSCode one) works perfectly fine, but I have to escape with exit() when clicking the green run button.
my terminal is running on python 3.8 and I don't have the terminal when I open the terminal it opens like below:
here is the image of terminal right after i open it
what should I do to get rid of this problem and go to normal terminal?
however I think it is because a package I installed on atom named build-python please help me.I think it is a child process but I couldn't kill it
edit : i forgot to say that when I press Ctrl+D in order to exit the python on terminal I get following screen:
here is the image
This question already has an answer here:
How to hide the python console window in Pyinstaller
(1 answer)
Closed 2 years ago.
I have a python script that is supposed to be running in the background. I used pyinstaller to create an executable file for the script. Now, this file opens up a terminal window. I don't have anything that is going to be printed on the terminal window, so I want it to close up just after starting up the process. How can I do that? Right now I just have a continous loop like this:
while True:
myFunction()
time.sleep(some-arbitrary-timeout-value)
Based on the context given, I will give you several options here for you to choose:
python pyinstaller.py --noconsole yourscript.py
You won't see the console window when executing your file.
nohup python your_executable.py & Keeps the script running even if you close the terminal
pythonw test.py similar to nohup, works on windows
you can launch your script and detach it from the terminal console by :
on linux you can use nohup & : nohup python your_executable.py &
on windows you can look at nohup on windows on stackoverflow
I'm working through Think Python chapter 4, where they tell you to type the following to see if you have the turtle module:
import turtle
bob = turtle.Turtle()
This is supposed to open a new window, but instead, it crashes my computer. I've seen it freeze my computer where I can't move the cursor or change windows, and I have to restart it. And I've also seen it close all my programs and re-open them.
I'm running Python 3.7 downloaded from Anaconda on a Macbook Air with Mojave version 10.14.6.
EDIT: When I run BenajahTX's suggestion below, I get this error message printed 16 times:
CGSTrackingRegionSetIsEnabled returned CG error 268435459
Any clue what is causing this or how to fix it?
try and set the screen and mainloop
window = turtle.Screen()
window.setup(width,height)
while True:
window.update()
window.mainloop()
Try running the file in the terminal using the command:-
$ python filename.py
I had the same issue and I was VS code extension Code Runner to run the python file, however, when I tried the terminal it worked and the mac OS was not crashing this time
I have a rather small Pygame based python script and I just bought a Mac so I'm trying to run my script on here. Everything has been installed correctly (Checking by typing 'import Pygame') into python terminal as-well as running a basic hello world program. However, when I try running this script, IDLE gets brought to the front but nothing happens from there. (The script is supposed to pop-up a new window). Is this a problem with my installations or my code? (Code works on windows setup).
You could try to run the script again on a windows computer to see if you forgot to save some changes or if the file got corrupted somehow. You could also use bootcamp to install Windows on your mac since you could have one windows version on your mac for coding purposes and the regular mac OS for other stuff if you like.
you can execute it by left clicking in your script and select open with python launcher