Questions tagged [sys]

For questions about the Python module named sys. This tag is also used for questions relating to the Sys namespace - the root namespace for the Microsoft AJAX Library, which contains all fundamental classes and base classes.

1100 questions
1
vote
1 answer

String input with wrong output using linux command

I created a python program, test.py, below: import subprocess import sys, os FolderPath = subprocess.getoutput("cd . && pwd") ProgramName = sys.argv[0] LogName = ProgramName[:-3]+'_printout.txt' ProgramFile = FolderPath+'/'+ProgramName LogFile =…
Peter Chen
  • 1,464
  • 3
  • 21
  • 48
1
vote
2 answers

sys.exit() causes an unexpected error causing the "repl process to die unexpectedly"

I am using repl.it to code a login/registration screen. The code in Python is below: while True: print(""" ============MAIN MENU================ *Welcome* 1. Register 2. Login …
Compoot
  • 2,227
  • 6
  • 31
  • 63
1
vote
3 answers

Python random number program

I'm trying to write a program that has a function that takes in three arguments and prints one integer. Specific details: Argument #1 should correspond to the size of a np.randint that has values from 0 to 10. Argument #2 is an integer that you…
CTate901
  • 13
  • 4
1
vote
1 answer

How to read after a space until the next space in Python

I have this program: import sys import itertools from itertools import islice fileLocation = input("Input the file location of ScoreBoard: ") input1 = open(fileLocation, "rt") amountOfLines = 0 for line in open('input1.txt').readlines( ): …
vapouryh
  • 41
  • 6
1
vote
1 answer

Twofold Question; Calling a random integer in a range through a function in Python 3.9

This is really a twofold question, since I know there are two errors with the same couple blocks of code. I'm essentially making an interactive story that changes based on "rolling a d20." For instance, the player is presented with a scenario, and…
R3TURN-0
  • 83
  • 1
  • 9
1
vote
3 answers

Why sys.path.insert not using the latest python package?

List below is my project structure. ├── folder1 ├── test.py ├── folder2 ├── A.py ├── folder3 ├── A.py A.py in folder2 and folder3 are the same except self.key #folder2 class TestAPI(): def __init__(self): self.key = 50…
haojie
  • 593
  • 1
  • 7
  • 19
1
vote
0 answers

ImportError: No module named os | trying to run .exe programm

I'm using Ubuntu 20.10 and I am relatively new to Linux so I would like to kindly ask you to tell me if there is any info needed. I am trying to install Ableton Live 10 in Ubuntu but I get this when I try to wine program_name.exe wine Ableton\ Live\…
The1Jaf
  • 11
  • 1
1
vote
1 answer

python can not find the fits file when using sys.path.insert

I would like to access the output of another python program that extracts information from a fits file. I usually do this in the following way: import sys sys.path.insert(1, '/software/xray/Python_scripts') from program2 import results However, in…
Sara Krauss
  • 388
  • 3
  • 17
1
vote
2 answers

quitting heroku app from within python script

I have a Heroku app running a discord.py bot and I want to make a remote shutdown command. If I was running from bash i could just do this with exit() or sys.exit() but neither of these work in Heroku as the app will startup again after the exit()…
Tanuj KS
  • 155
  • 2
  • 14
1
vote
2 answers

python sys.argv in classes name.py [list of integers 2, 4,..], integer

I wanna pass 2 arguments, one as list [8, 10], and one as integer in terminal. file MySeq.py like: MySeq.py [8, 10], 32 How would i do this? import sys class MySeq(): def __init__(self, positions, length): self.positions = positions …
1
vote
0 answers

echo 1 > /sys/devices/system/cpu/cpu3/online Write error

I'm using the kernel uname -r 5.8.13-050813-generic In latest version due to 'CPU HOTPLUG' 2 CPU's are online and other 2 are offline nproc 2 lscpu On-line CPU(s) list: 0,1 Off-line CPU(s) list: 2,3 I tried sudo su root:…
Dharma B
  • 21
  • 9
1
vote
1 answer

Azure Managed instance Could not find stored procedure 'sys.sp_MS_marksystemobject'

I am a sysadmin on the server (Azure Managed Instance), I am trying to create system procedures in master database and mark them as system using [sys].[sp_MS_marksystemobject] procedure in n Azure Managed instance but I get object not found on…
Gokhan
  • 279
  • 3
  • 13
1
vote
0 answers

sys.argv to python readable string

I have a node app that calls a spawn python process like so: const python = spawn('python3', ['python/rimas_definitivas.py', input]); the input variable comes from a form in the browser, and it usually has special caracters, like "á", "õ", ... in…
1
vote
2 answers

How can i find the first n negative integers by using an array

I wanted to find a way i can the first n negative integers so if i put in 7 it would produce [-1,-2,-3,-4,-5,-6,-7] import stdio import sys n = int(input(sys.argv[0])) arr= list(range(-1,n)) print(arr)
user14267508
1
vote
0 answers

sys.stdout only creates an empty file

I have a bit of code that reports result of CV and hyperparameter optimization. I'm trying to print out the results to file. The file gets created but doesn't print the results there. It also doesn't print them to terminal. What's wrong? def…
Orion
  • 65
  • 1
  • 9