Questions tagged [python]
Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
2,343 questions
0
votes
1
answer
128
views
Is it existing better way to create user and password with salt tools
Here my salt dependencies and system version :
#~: salt -V
Salt Version:
Salt: 3000
Dependency Versions:
cffi: 1.11.5
cherrypy: Not Installed
dateutil: Not ...
0
votes
2
answers
139
views
Nesting quotes in shell
I want to execute a command which looks like
$ sh -c 'exec python -c "print('$1$2MyString')"'
with the desired result '$1$2MyString'.
However, when I execute the command, I get
Traceback (...
0
votes
0
answers
175
views
Can't restart a suspended process
I execute a long running Python-process. To stop the annoying noise from the fans I use AppPolice to prevent this process from using more than 20 % CPU (I don't care when it finishes).
I think that ...
0
votes
0
answers
171
views
how to install missing python modules offline without managers
I have a device running an embedded OS (Custom Linux buildroot). It is offline and has no package manager (apt, yum, et al.) and Python has several missing modules, one of which is key for our ...
1
vote
4
answers
188
views
Remove duplicates by adding numerical suffix
How do I append a numerical suffix to lines to remove duplicates?
Pseudo code:
if currLine.startsWith("tag:")
x = numFutureLinesMatching(currLine)
if (x > 0)
currLine = currLine + ...
0
votes
1
answer
186
views
Script not working fully under systemd
I have a python script to switch light/dark mode.
At the end there's this line:
process = subprocess.Popen(binDir + "/polybar.sh")
That script it points to is this:
#!/bin/env bash
# ...
1
vote
0
answers
98
views
echo or >> (or something) fails when network connection has been idle for a long period?
I have a script that takes several hours to finish (the script runs whisper and it is the whisper . At the end I echo and >> some results to a network volume mounted using SMB. This often fails ...
0
votes
1
answer
934
views
How to `import FreeCAD` in CLI (python)
How can I import FreeCAD from the python console?
I'm trying to write a script that can manipulate a given FreeCAD file, but I can't even get FreeCAD imported into the python console on a system where ...
0
votes
1
answer
160
views
Why can't I change my pip3 from the built in to the MacPort-version?
Here is a terminal session:
db@air ~ % port select --list pip3
Available versions for pip3:
none
pip3-apple (active)
pip311
db@air ~ % sudo port select --set pip3 pip311
...
1
vote
2
answers
200
views
Adding a newline above PS1 that survives prepending
In OBSD ksh, I had a PS1 which prepended a blank line:
PS1="\n[\u@\h] \w\n\$"
The problem with this was that pyenv prepends the name of a virtual environment when that environment is ...
-1
votes
1
answer
108
views
Complicated DIFF method
I'm trying to do a compare between a config from an old box and a new box to verify Availability and State haven't changed.
I have a file that is generated with about a thousand nodes but every node ...
0
votes
3
answers
589
views
How do I use grep, awk, or sed to get a substring of a line up until a string literal?
I am trying to process a text file and omit a certain string literal if it occurs at the end of the line. E.g.:
Source:
ABC 123
DEF, characters I don't want
GHI, these characters are ok
Desired ...
0
votes
0
answers
95
views
Not a directory but have contents
So I use Compute Engine VM in Google Cloud to download youtube videos. I use Youtube-dl to download it. I follow the documentation in here: https://github.com/ytdl-org/youtube-dl/blob/master/README....
0
votes
1
answer
1k
views
Plotting a two dimensional array using matplotlib python
I want to be able to plot an array of functions that are stored as a 2-d array using matplotlib. They all have the same independent variable. Specifically,
P=zerros((ntotx, ntoty),float)
x=zeros(ntotx,...
0
votes
2
answers
996
views
vscode with jupyter with archlinux
I am trying to install and use vscode with jupyter extension for coding with python on my archlinux OS. but it does not found any kernel interpreter
I installed both jupyter and python extension in ...
0
votes
1
answer
1k
views
ModuleNotFoundError: No module named 'debpython' [closed]
After some manipulations with updating Python to version 3.9 and using the command "python" to invoke Python 3.9 (update-alternatives), or perhaps something else, I encountered a global ...
0
votes
1
answer
4k
views
How to activate python venv in a non-bash shell?
I see most tutorials/online sources advice using either source or . (a bash built-in) to activate a python venv. For example, this page suggests to do the following in Linux:
cd ~/<proj_name>
. ...
1
vote
1
answer
174
views
Shell Variable Expansion in qsub command through drmaa
I am running a bulk job submission to SGE (Sun Grid Engine) using python drmaa bindings.
For the bulk job submission I am submitting a python script that takes in one argument and is command line ...
1
vote
1
answer
666
views
Delete VM including storage with python-libvirt
I'm trying to write scripts in Python with the libvirt library, but there's one thing I'm currently stuck at.
I can successfully create a VM, set it up how I want it, start it, access it, and shutdown ...
0
votes
0
answers
306
views
My Crontab doesn't work on Raspberry Pi
I have a python script in:
/home/pi/auto/wake_up.py
crontab -e:
* * * * * /usr/bin/python /home/pi/auto/wake_up.py >> /tmp/wake_up.log
log is created but with empty line
same when I put
#!/usr/...
0
votes
1
answer
125
views
Do I need to recompile Vim if Python changes a minor version?
I use a compiled Vim on my machine.
This compiled vim attempts to load the shared libary libpython3.10.so.1.0
I just updated my system and apparently Python deleted the old Python 3.10 libaries and ...
0
votes
1
answer
529
views
Filtering log statements before they're written
I have an application I need to run in verbose mode to get the information I'm interested in. This produces an enormous log file that is <1% interesting for my requirements.I want some way of ...
0
votes
0
answers
179
views
After installing meld via pip, I can't run it
I've installed meld as a non-root user via pip install meld (on a relatively old distribution - SLES 15).
After installation, I see a file named /home/joeuser/.local/lib/python3.6/site-packages/meld/...
0
votes
1
answer
268
views
Python subprocess output is logged by systemd twice
In my application, I have the following code:
def ifdown(iface):
rc = subprocess.run(['/sbin/ifdown', iface]).returncode
if rc:
print(f'ifdown({iface}) returned {rc}')
return ...
1
vote
3
answers
659
views
Create a list of directories from list of paths and create a blank text file in each directory
The input is a list of paths. Everything but the first directory should be ignored / deleted.
For example a text file called dirnames or dirs is input with these 3 lines of text:
/how-to-blah-blah/
/...