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.
Questions tagged [sys]
1100 questions
33
votes
2 answers
redirect sys.stdout to specific Jupyter Notebook cell
Jupyter==4.1.0, Python==2.7.10, IPython==4.2.0
I'm writing a SQL UI for my Jupyter Notebooks and would like to incorporate multithreading so that I can run a query in one cell and continue to work in other cells while the query is running.
The…

tmthyjames
- 1,588
- 2
- 22
- 30
32
votes
9 answers
How to connect in java as SYS to Oracle?
I receive this error:
java.sql.SQLException: ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
How to fix? (I need to be SYS).
Thanks.

user710818
- 23,228
- 58
- 149
- 207
30
votes
5 answers
DataGrip: how to connect to Oracle as SYSDBA
I tried to setup in DataGrip an Oracle connection under SYS user.
But got error:
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
But there is no option in GUI to choose as SYSDBA option.

Vadzim
- 24,954
- 11
- 143
- 151
30
votes
2 answers
How can I import files in Python using sys.path.append?
There are two directories on my desktop, DIR1 and DIR2 which contain the following files:
DIR1:
file1.py
DIR2:
file2.py myfile.txt
The files contain the following:
file1.py
import sys
sys.path.append('.')
sys.path.append('../DIR2')
import…

makansij
- 9,303
- 37
- 105
- 183
27
votes
7 answers
What cool hacks can be done using sys.settrace?
I love being able to modify the arguments the get sent to a function, using settrace, like :
import sys
def trace_func(frame,event,arg):
value = frame.f_locals["a"]
if value % 2 == 0:
value += 1
frame.f_locals["a"] =…

Geo
- 93,257
- 117
- 344
- 520
24
votes
7 answers
Python: Which encoding is used for processing sys.argv?
In what encoding are the elements of sys.argv, in Python? are they encoded with the sys.getdefaultencoding() encoding?
sys.getdefaultencoding(): Return the name of the current default string encoding used by the Unicode implementation.
PS: As…

Eric O. Lebigot
- 91,433
- 48
- 218
- 260
21
votes
1 answer
How to open files given as command line arguments in python?
I want my .py file to accept file I give as input in command line. I used the sys.argv[] and also fileinput but I am not getting the output.

Ram
- 547
- 2
- 4
- 13
20
votes
2 answers
python command line arguments in main, skip script name
This is my script
def main(argv):
if len(sys.argv)>1:
for x in sys.argv:
build(x)
if __name__ == "__main__":
main(sys.argv)
so from the command line I write python myscript.py commandlineargument
I want it to skip…

CQM
- 42,592
- 75
- 224
- 366
19
votes
4 answers
How to make sys.argv arguments optional?
sys.argv takes arguments at the shell command line when running a program. How do I make these arguments optional?
I know I can use try - except. But this forces you to insert either no extra arguments or all extra arguments, unless you nest more…

Bentley4
- 10,678
- 25
- 83
- 134
18
votes
2 answers
How to view syslog in ubuntu?
Follow up from this question, LogBack Syslog not working java
I use command below to view syslog in ubuntu 16.04 but get below result. Is it the correct way to view?
user@xxx:~$ tail -f /var/log/syslog Jun 6 23:08:50 xxx systemd[1]:
Starting…

Tony
- 2,515
- 14
- 38
- 71
17
votes
4 answers
Jupyter notebook, wrong sys.path and sys.executable
I'm trying to run the anaconda distribution of python libraries in a Jupyter Notebook, but when I run the notebook I keep getting ImportErrors because the python path is set to the default distribution from Mac OS X 10.11
When I print out the…

Glenn Raskovich
- 341
- 1
- 3
- 8
14
votes
7 answers
How do you convert command line args in python to a dictionary?
I'm writing an application that takes arbitrary command line arguments, and then passes them onto a python function:
$ myscript.py --arg1=1 --arg2=foobar --arg1=4
and then inside myscript.py:
import sys
argsdict = some_function(sys.argv)
where…

priestc
- 33,060
- 24
- 83
- 117
13
votes
2 answers
Kubernetes 1.11 could not find heapster for metrics
I'm using Kubernetes 1.11 on Digital Ocean, when I try to use kubectl top node I get this error:
Error from server (NotFound): the server could not find the requested resource (get services http:heapster:)
but as stated in the doc, heapster is…

FakeAccount
- 242
- 1
- 3
- 19
13
votes
2 answers
knitr - error when importing python module
I am having trouble when running the python engine in knitr. I can import some modules but not others. For example I can import numpy but not pandas.
{r, engine='python'}
import pandas
I get the error.
Quitting from lines 50-51 (prepayment.Rmd)…

Glen Thompson
- 9,071
- 4
- 54
- 50
13
votes
1 answer
Detect from a running python script if the optimize flag is -O or -OO
Sometime I'd like to spawn a child process with the same optimization flags used to start the parent.
I can use something like:
optimize = not __debug__
But this way I match both -O and -OO flags.
Is there some python internal status that contains…

naufraghi
- 1,514
- 13
- 16