Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [python]

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.

0
votes
0answers
5 views

Using `ipdb` to debug Python scripts run as Slurm jobs

I sometimes use import ipdb; ipdb.set_trace() in order to debug Python code with iPython (as described here: Step-by-step debugging with IPython). I also sometimes submit jobs to a computing cluster ...
0
votes
0answers
18 views

running python flask app with virtual environment (VENV) on VPS in background

I am trying to run a flask app on my VPS in production environment. The problem is that I can't alter any of the VPS packages, and it uses a python3.5 interpreter as default. The version that is ...
-1
votes
1answer
34 views

cumulative table, create new table in which values in each column are sum of each previous column values [on hold]

I am dealing with script to transform table - in output table each column should be a sum of previous columns (something like cummulative table). Table got unknown number of rows and columns, first ...
0
votes
1answer
8 views

Python application which is running inside a docker container is not showing up

I have created a python application using flask module and tested it locally and it is working fine. So i have tried to deploy it using a ubuntu docker container, but now the application is not ...
0
votes
0answers
19 views

Use subprocess in python to echo a variable [migrated]

I have a variable in python, and I'm trying to open a subprocess and echo the variable, then create a file with the variable in it. I tried this: subprocess.Popen(['echo "$var" > file.txt'], shell=...
0
votes
0answers
16 views

Relocation Error with python3 and GLIBC

I have an ubuntu machine that has been running some home automation software for a while. I went to go do an update of the HA software and got an error that lsb_release failed. When I run ...
0
votes
2answers
58 views

Is there something similar or like “pass” in python in bash/shell programming?

I sometimes need a command like pass in Python in my bash scripts. Like: if grep something then pass else code fi In Python you have: >>> for element in a: ... if not element: ...
0
votes
3answers
33 views

Extract a string out of key, value from a text file, and assign to a new variable

Need a script to iterate through below file to read keys, values and extract values eg. foo_key1, foo.com, /tmp/worker${Build_Number} out of key and values assign them to another variable (eg. A="...
0
votes
1answer
46 views

How to pass argv arguments to a C program using a file or python script in linux?

I used to be able to pass input to C program by first writing a python script and using pipe to send it to the C program as an input or write the output of python script to a file and just doing r &...
0
votes
0answers
7 views

Configure logging permissions for Supervisord with Apache2 mod-WSGI + Tornado

I'm running Tornado Python application behind apache2 mod-wsgi served by supervisord. My supervisord config looks like [supervisord] nodaemon=true logfile_maxbytes=50MB ; (max main logfile ...
0
votes
0answers
15 views

Sequentially print data output as a formatted table in Python [migrated]

I have written a Python script to execute data like My script : import os import os.path import re import smtplib from email.mime.text import MIMEText infile = r"D:\i2Build\i2SchedulerReport.txt" ...
0
votes
3answers
53 views

Patching a bash function

I have a shell function (ok, it's the deactivate() function defined by a Python virtualenv), and I would like to patch it by inserting some statements before or after it's executed. My goal is to have ...
-1
votes
2answers
35 views

How to save a number from a text file in python? [closed]

I have a text file, from which I have to extract a number, which is in the line called "width:" It is like: width: 3432 Now I am trying: import re file = ...
-1
votes
1answer
18 views

how to get te 2. element of the 11. line with python? [closed]

I have a text file, and I want to save the second elemnt od the 11th lines as an element. The file looks like this: WIDTH: 32554 I am trying to get it with this: z = open('abcd.txt') lines = z....
0
votes
3answers
940 views

Is Python mandatory for Linux? [closed]

One of my friends told me that without Python, Linux cannot get ip, cannot open network stack and can't make "port switching", even he thinks kernel can't boot without Python. What do you think about ...
1
vote
2answers
42 views

How do I analyze journalctl logs outside of journalctl?

I need to collect some stats from my systemd log files, like how many users pass in a certain query string parameter to my service. I know I can view this information in journalctl but I can't figure ...
1
vote
0answers
30 views

How to setup qemu networking for web app server on guest?

I am trying to setup a simple test system emulated under qemu. Problem is I seem unable to connect to web applications using the standard command line because applications usually listen to a well ...
0
votes
0answers
95 views

RHEL 6.8 installation of user specific python 3.7 completes with 'ModuleNotFoundError: No module named '_ctypes'

I do not have a subscription to the RHEL repos at this time. I am using EPEL for packages that are needed. Goal: I am attempting to setup multiple virtualenv folders for testing purposes. I have ...
0
votes
0answers
31 views

sed command execution in Python [closed]

command = '''out=$(%s);echo $out | sed -n 's/.*"Id": "\(.*\)", "Created".*"Status": "\(.*\)", "Running".*"Pid": \(.*\),.*"ExitCode": \(.*\), "Error".*"Name": "\/\(.*\)", "RestartCount".*"Privileged": \...
0
votes
0answers
49 views

systemd “status=203/EXEC” error when creating new service

I've created a new service for a Python script that works when running standalone but gives errors below when run through systemd : Oct 02 12:17:09 raspberrypi systemd[1]: Started Read pressure And ...
0
votes
0answers
11 views

Segmentation fault when using `curses` in Python on Ubuntu 18.04 [migrated]

I recently upgraded from Ubuntu 16.04 to Ubuntu 18.04 (directly, skipping intermediary versions). Since the upgrade python is Segfaulting when I try to use the curses module. This happens in both ...
0
votes
1answer
37 views

Issues running pip command

I am running Centos 6.10. My pip version is 7.1.0. When I run pip. I get the following output: Traceback (most recent call last): File "/usr/bin/pip", line 7, in <module> from pip....
0
votes
2answers
39 views

environment variables script

There's several centos linux boxes at my workplace. I've been tasked with creating some form of environment variable tool for them. The idea is the user runs the tool, with the argument of their ...
-1
votes
1answer
14 views

Error in importing dbus in python on ubuntu 16.04

I am trying to import dbus in a python script. But I am getting the following error Traceback (most recent call last): File "playSong.py", line 4, in <module> import os, dbus ...
2
votes
2answers
59 views

yum stopped wokring on my ec2 instance

I have an EC2 instance on which I was trying to install spark.I removed the required system python version from the system by mistake and nothing relying on python seems to work now including yum and ...
0
votes
0answers
8 views

Python RegEx to Catch White Space Between Array Name and Size [migrated]

I am using a regular expression in a python script to search through a file to find variable declarations. This is what I have so far: ret1 = re.compile(r'^\s*(volatile|register|typedef)?\s?([\w<&...
0
votes
2answers
59 views

CentOS7 Python Security Update

I would like to know how to install a security update for Python 2.7.5. I was notified that my CentOS 7 Python version had a security patch update. The details are here: https://lists.centos.org/...
0
votes
0answers
17 views

Converting bash script to python [migrated]

I am trying to convert a bash script to a python. This is the bash code: number=1 /sbin/lsof -i -P -s tcp:LISTEN | while read -r line; do if [ "$number" -eq 1 ] ; then number=$((number+1)) ...
0
votes
1answer
44 views

display the file descriptors of a process using python [closed]

How can I display the open file descriptors of a process in linux using python script? I tried using readlink /proc/PID/fd/* in python script but I am getting error. /bin/sh: 2: /fd/*: not found ...
1
vote
1answer
49 views

How to pass string with trailing whitespace to python's subprocess

I would like to batch rename files that have trailing spaces to the same name without the spaces. In python 3.6.5, the following works fine: subprocess.call("mv '%s' '%s'"%(name,name.strip()),shell=...
0
votes
0answers
31 views

Why PyPy considers “timeit” as unreliable tool for Python performance measurement? [migrated]

PyPy warning about timeit: (my-pypy-env) $ python -m timeit --setup "from simulation import benchmark" "benchmark()" WARNING: timeit is a very unreliable tool. use perf or something else for ...
-2
votes
0answers
28 views

Issues executing wine pyinstaller

Linux Version: Debian 9 Strech amd64 wine version: 3.0.2 python version : 2.7.15 I tried to run pyinstaller using wine but When I type: "wine pyinstaller -v" I get this error: 002e:err:winediag:...
0
votes
0answers
17 views

Accepting comma separated numbers along with splitting blanks in python [migrated]

I am trying to accept a sequence of integers separated by comma and would like to trim any blanks that come along with it. I am using below code. values = raw_input("Input some comma seprated numbers ...
0
votes
1answer
28 views

Translating a string with a python script, using bash, consecutive times?

#!/usr/bin/python3 import argparse vokaler = "aouåeiyäöAOUÅEIYÄÖ" konsonanter = "bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ" def viskspraket(text): """Removes all vowels from the sentence""" ...
0
votes
2answers
23 views

python script doesn't appear to be executed but no errors show

I have a python script that I would like to run through cron every minute * * * * * /usr/bin/python3 /home/analytics/Documents/devDeliverables/attendanceReadTsv/check_raw.py when I run this using a ...
0
votes
0answers
27 views

VirtualBox and Python version conflict

I am running Debian (buster) with Cinnamon as window manager. Recent update of this window manager required Python update so my current Python version is 3.6.5-3... but on the other hand virtualbox ...
0
votes
2answers
41 views

How can I iterate over files in a given directory, and check if file exist?

Here is the files list in a given directory; a_object_1.0.zip file_name_conf_1.1.zip anim_dup_1.1.zip Iterate over files in a given directory, and check if file matching the file pattern from the ...
0
votes
5answers
78 views

How do I delete all lines in a file until it matches a string line pattern? [duplicate]

How can I delete lines in a file until it matches a string line pattern? cat test.txt The first line The second line The third line The fourth line pen test/ut The sixth line The seventh line I ...
0
votes
0answers
30 views

Cant boot linux mint gui from terminal startx goes to black screen with working mouse xlog error

xinit-> X.Org X Server 1.19.6 Release Date:2017-12-20 X Protocol Version 11, Revision 0 Build OS: Linux 4.4.0-119-generic x86_64 Ubuntu Current OS: Linux laptop 4.15.0-20-generic #21-Ubuntu SMP Tue ...
2
votes
1answer
40 views

Systemd - Find .Xauthority file to use

I'm currently using a systemd unit file to configure a service which uses X server display. The X server instance is launched by the user logged in (currently pi user) but the service is launched at ...
3
votes
2answers
50 views

Shell script to autostart script

I would like to refer to my previous post here: Autostarting a python script whenever it crashes to restart two python scripts on my raspberry pi (Stretch OS) if they crash. The code of the shell ...
0
votes
0answers
19 views

Installation error for OpenVPN and other apps - Something phython2.7 related

I'm trying to install OpenVPN on Ubuntu 18.04 to setup a VPN - but it shows some weird error that says the following: The directory '/home/myusername/.cache/pip/http' or its parent directory is not ...
2
votes
3answers
53 views

How to avoid single quotes in file name during python saving file?

If Python saves file on extended 4(Linux) partition that contains unusual symbol(so far uncovered square brackets [] ). It automatically quotes file name. For example: file[].txt will be saved as '...
1
vote
0answers
26 views

Windows PDF viewer interprets hyperlinks incorrectly from Linux converted PDF?

I am operating on a RPi Model 3B with Jessie OS and Python version 2.7.9. I am using XlsxWriter (ver1.1.0) to write an .xlsx file and then converting it to PDF using LibreOffice's conversion code, as ...
2
votes
1answer
263 views

How to change python default version from 2.7 to 3.7 on RHEL 7

How to change python default version from 2.7 to 3.7 on RHEL 7. Installed python on RHEL7 virtual machine by following this https://tecadmin.net/install-python-3-7-on-centos/ When I check python ...
0
votes
0answers
88 views

Errors were encountered while processing: python-minimal

I can't do anything with apt-get because of python-minimal. I think I may have corrupted my python! Whenever I want to install, remove, or upgrade using apt-get, it gives me this error: Errors were ...
1
vote
0answers
39 views

Build C executable with env variables via Makefile [closed]

I have huge application written in C and Python. I have a Makefile which helps to build final executable on several platforms. Here's a main part (I can't expose too much because of confidential info):...
1
vote
1answer
19 views

How to recover from a major mistake that breaks yum

I was attempting to update my CentOS 7 system tonight and kept getting an error from python-urllib3. I tracked down the error to a directory that should not have been present. So, I went to remove ...
0
votes
2answers
66 views

Where to store proprietary code and executable scripts? [closed]

I have Python code that is run using a bash script. I want non-sudo users to be able to run it without making the Python code readable. What is the recommended pattern? Two ways I considered: Put ...
-1
votes
1answer
38 views

Pyenv cannot be installed in Manjaro Linux

Hello I have been trying to install pyenv on Manjaro Linux and got an error that openssl is not installed on the system.  I have now installed it. I understand that I am supposed to tell the compiler ...