sys

Using Python, why would sys.exit(0) hang, and not properly close a program?

Using Python, why would sys.exit(0) hang, and not properly close a program? Question: The bug I am running into is that sys.exit(0) is not properly closing my program. I use pyinstaller to make this program an exe. When I use the exe, the program has to be shutdown using task manager. (I am running the …

Total answers: 1

Taking txt files with unknown names as parameters (Python)

Taking txt files with unknown names as parameters (Python) Question: I am trying to write a program in Pycharm that can take the name of 2 txt files as an input and then use that input to execute some set of instructions. I understand I can put the name of a txt file in the …

Total answers: 1

ModuleNotFoundError even though the Module is present

ModuleNotFoundError even though the Module is present Question: I am getting a ModuleNotFoundError for a module that exists. I have a __init__.py and imported sys but I am still getting a ModuleNotFoundError error on my django error. My file structure: |-my_app |-folder1 |-__init__.py |-calc.py |-folder2 |-__init__.py |-test.py I want to import a function from test.py …

Total answers: 2

sys.path.append which main.py will be imported

sys.path.append which main.py will be imported Question: If I have a project with two files main.py and main2.py. In main2.py I do import sys; sys.path.append(path), and I do import main, which main.py will be imported? The one in my project or the one in path (the question poses itself only if there are two main.py …

Total answers: 2

Return normal terminal input when using tty, sys, terminos

Return normal terminal input when using tty, sys, terminos Question: I’m working on a little project which requiers input without "pausing" for each time. Without completely understanding how it works, I used some code that I found online. import tty, sys, termios while True: filedescriptors = termios.tcgetattr(sys.stdin) tty.setcbreak(sys.stdin) dir_inp = 0 while 1: dir_inp = …

Total answers: 1

serial in sys.version_info of python

serial in sys.version_info of python Question: The sys.version_info output is (‘major’, ‘minor’, ‘micro’, ‘releaselevel’, ‘serial’). I find that most of the explanations of this function outputs serial=0. I really don’t understand what is this ‘serial’? What does it mean? Why is it always 0? Asked By: liaoming999 || Source Answers: The .serial part of the …

Total answers: 1

What is 'sys.is_finalizing' and when it's useful?

What is 'sys.is_finalizing' and when it's useful? Question: The sys module have a function called is_finalizing. Running help(sys.is_finalizing) will result in >>> help(sys.is_finalizing) Help on built-in function is_finalizing in module sys: is_finalizing() Return True if Python is exiting. What is mean by Python is exiting? The [documentation(https://docs.python.org/3/library/sys.html#sys.is_finalizing) says this, sys.is_finalizing() Return True if the Python …

Total answers: 1

why i am getting – file cannot be loaded because running scripts is disabled on this system

why i am getting – file cannot be loaded because running scripts is disabled on this system Question: While loading a python file in pycharm i am getting the following warning, earlier it was not there also print(‘Hello’) is working as expected but i am not able to install django. File C:UsersabhiPycharmProjectsdjango_appsvenvScriptsactivate.ps1 cannot be loaded …

Total answers: 2

Run Python Script from another script and redirect script output to text file

Run Python Script from another script and redirect script output to text file Question: I would like to run a second Python script and to redirect the output of this second script to a text file. The scripts and the text file are in the same folder. I tried: import sys import os path = …

Total answers: 2