terminal

Jupyter Notebook "!" command not using Virtual Environment

Jupyter Notebook "!" command not using Virtual Environment Question: As we all know we can use !<command> to ensure the cell runs a terminal command. However if we usepip install lxml it installs lxml in the root python kernel and not the kernel environment that we mention in Jupyter. With !command in jupyter notebook, any …

Total answers: 2

os.system file names with spaces

os.system file names with spaces Question: Here is my python code (I am on Mac osx) os.system("open Applications/Google Chrome") I cannot figure out how to make spaces, or how to make this work. Can someone tell me how to make terminal understand this? Asked By: zonellobster || Source Answers: You need to add quotation marks …

Total answers: 1

PowerShell setting environment variable to subexpression discards newline

PowerShell setting environment variable to subexpression discards newline Question: I have a python script: # temp.py print("foonbar") I can run this in powershell: > python .temp.py foo bar I want to set the environment variable FOO to the output of this python script. However, doing so changes the newline to a space: > $env:FOO=$(python .temp.py) …

Total answers: 1

python runs older version after installing updated version on Mac

python runs older version after installing updated version on Mac Question: I am currently running python 3.6 on my Mac, and installed the latest version of Python (3.11) by downloading and installing through the official python releases. Running python3.11 opens the interpreter in 3.11, and python3.11 –version returns Python 3.11.0, but python -V in terminal …

Total answers: 1

How to print RGB colour to the terminal

How to print RGB colour to the terminal Question: Can ANSI escape code SGR 38 – Set foreground color with argument 2;r;g;b be used with print function? Example of use with code 33 is of course OKBLUE = ’33[94m’ I would like to use 038 instead to be able to use any RGB color. Is …

Total answers: 3

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

How to return a list from a class

How to return a list from a class Question: How would I get to return a list from the class, right now its just returning the location class ListNode: def __init__(self, val=[]): self.val = val def __iter__(self): return iter(self.val) def file_reader(file_path): list_of_num = [] with open(file_path, "rt") as fout: reader = csv.reader(fout, delimiter=",") for line …

Total answers: 1

Python OS module stalls after new processes starts

Python OS module stalls after new processes starts Question: I am trying to write a Raspberry Pi Python-3 script that turns on an IR receiver using a call to os.system() with mode2 as the argument. When this line of code executes, the mode2 process starts and runs properly (I can see it working in the …

Total answers: 1

Is there a way to make the terminal blink when python script finishes running?

Is there a way to make the terminal blink when python script finishes running? Question: I created a python script to call some API. I want to be informed when it’s finished. Is there a way to prevent me from checking the status in the terminal constantly? For example, Can python make the terminal blink …

Total answers: 1