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
3
votes
1 answer

Open PDF with default program in Windows 7

I have a program in which the help documentation is in a .pdf in the same folder as the .py module. I need the program to open the .pdf with the system's default PDF reader. I am using this code in my program: if sys.platform.startswith('darwin'): …
CodeMouse92
  • 6,840
  • 14
  • 73
  • 130
3
votes
1 answer

Doctest not working in Sphinx, cannot import python files Python

I have a problem trying to run doctest from the Sphinx Tutorial. I have the directory tree below but I cannot run a doctest for lumache.py. How would be able to make it so that lumache.py is importable with the pathlib function in conf.py which is…
Bosser445
  • 303
  • 1
  • 9
3
votes
2 answers

Any idea why I would get "name 'sys' is not defined" after creating a new MongoClient object in Python?

I'm working on a Discord bot that saves some data to a mongodb database in response to some user commands. The weird thing is it works on repl.it, but I get this error on SparkedHost. I'm getting an odd error when I create a new MongoClient Object.…
3
votes
2 answers

Executing system commands in python

I have experience with perl for writing scripts, which made it easy for me executing linux commands by using back-ticks. I was wondering, how can I do this Python ? Is there a special way for capturing the result of a command (output) ? thank you…
Lucas Kauffman
  • 6,789
  • 15
  • 60
  • 86
3
votes
0 answers

How to send an input to a running program in the command prompt in python

(i'm italian, sorry for grammar errors) I have made a simple programming language. In this language, to run an external file, you have to type 'RUN("file_name.extension")'. Then i started making a simple text editor in tkinter able to highlights my…
Damus
  • 31
  • 2
3
votes
4 answers

How to run a Python file with boolean arguments

I have a .py file with a single function that basically converts a .csv file to a .pkl file. This file, when invoked from the terminal, is supposed to convert the measurements between imperial and metrics depending on whether the input is true or…
Onur-Andros Ozbek
  • 2,998
  • 2
  • 29
  • 78
3
votes
2 answers

Why can my new user login as sysdba in oracle?

I just installed Oracle 11g R2 on windows 7 machine. I am able to login using my sys as sysdba account. Using the sys account I created a user as follows create user testuser identified by testuser; When I try to connect to database with testuser…
Ankur
  • 151
  • 1
  • 3
  • 5
3
votes
3 answers

Why is my program being interferred by comments?

Our tasks at school is to add a test example of the program at the bottom of the code with: #example """ """ but when I do so, I get error. I never get it on any other codes, only on this…
3
votes
2 answers

how to input multiple files in python script using sys.argv list

I want to take multiple files one by one into python script as input files and perform my script operations on all of those files one after another.I want to do this using sys.argv list but don't know how to do this properly. here is the piece of…
iqra khan
  • 45
  • 1
  • 6
3
votes
1 answer

Importing pandas module stops my script from working

I am using child_process model to send data to a python script, where I preform some calculations with pandas, and then send it back to a node.js script: index.js. The problem is that when I import the pandas module to the python script, it stops…
ulisman1
  • 35
  • 5
3
votes
2 answers

Is it possible to write to a python frame object as returned by sys._getframe() from python code running within the interpreter?

Apropos of This question, there is a bit of scaffolding within the interpreter to inspect frame objects, which can be retrieved by sys._getframe(). The frame objects appear to be read only, but I can't find anything obvious in the docs that…
ConcernedOfTunbridgeWells
  • 64,444
  • 15
  • 143
  • 197
3
votes
0 answers

Redirect TF_CPP logs to file python

I'm running python script in which I intend to save tensorflow logs (regardless of their severity) generated during the execution of the script, to a file so that they don't pop up on the console. Here's the code snippet: # Setting up Info…
Preetkaran Singh
  • 502
  • 5
  • 19
3
votes
1 answer

Why use getattr instead of hasattr for sys.frozen?

Every documentation and answer I could find, says that in order to check if the program is "frozen" (an exe for example), we can use getattr(sys, 'frozen', False) in the following way: import sys if getattr(sys, 'frozen', False): print('program…
Ofer Sadan
  • 11,391
  • 5
  • 38
  • 62
3
votes
0 answers

How can I remove '\r' in a loop to read files in python

Does anyone know how to get rid of '\r'? I have to run 89 files in the supercomputer, I have done so far the two next scripts The first one is .sh to run it on shell $ID=$(sed "${PBS_ARRAYID}q;d" ID_index.txt) $echo "Processing $ID" $python…
Ale Lope
  • 33
  • 3
3
votes
0 answers

What is the R's stop function equivalent in Python

I'm given a task of converting an R script to Python. I'm trying to understand the functionality. It is mentioned as below in the script. stop('The database argument must be supplied', call.=FALSE) Is this equal to Python's sys.exit?…
Underoos
  • 4,708
  • 8
  • 42
  • 85