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
16 views

Cron: Paramiko script, private RSA key invalid when run with crontab

I have a small paramiko script that runs wonderfully from interactive shell. However when run as a cron job in /etc/crontab it fails with paramiko.ssh_exception.SSHException: not a valid RSA private ...
-1
votes
1answer
40 views

How can I replace ~60 print entries in 5 different files using vim or sed?

Fabfile (directory) containing Python files: print "DEBUG fab_helper DRYRUN: True"+var print "DEBUG fab_helper DRYRUN: True" #print "DEBUG cfn_stackname: "+cfn_stackname To: LOGGER.DEBUG("DEBUG ...
0
votes
2answers
25 views

Copying portion of line as integer in Python scripting language [on hold]

I need to copy timing window into a variable from line of .txt file using Python. Input file: [Fri Dec 07 18:50:16.775 2018] [ 3.610065] dwc3 e2d00000.usb_core: SUCCESS allocating dump_regset ...
1
vote
1answer
38 views

program called twice from the command line [on hold]

Let's say I have a (Python3) script of my own named myscript; for various reasons, myscript (not myscript.py) is stored in a sub-directory named bin : mydir/ mydir/bin/ mydir/bin/myscript -rwxr-...
-7
votes
1answer
61 views

I HAVE TRY EVERY THING WITH THIS PIP BROKEN PROBLEM [on hold]

every time in i have this problem i just copy my files and install a fresh copy of kali and work again to update the system and copy redownload the requirement for my application i don't know exactly ...
1
vote
1answer
14 views

Is it possible to cache pip downloads in a http cache server?

I have a virtual linux machine with python2 and pip installed. I want to save bandwidth by caching pip downloads in a http cache server and use this cache server in other machines. The functionality ...
1
vote
2answers
41 views

search through all *.py files [duplicate]

I am using Mac OS terminal (similar to Linux) and trying to find best way to search inside all files on a computer that has extension *.py What is the best way to achieve this? I wanted to put 1 ...
-3
votes
1answer
19 views

Comparing two fields from two files and printing the common items from the files with the count from each file

I have two files in a below-mentioned way File1 Emp1 Dec10 12Am Emp2 Dec10 2Am Emp3 Dec10 4Am Emp2 Dec10 6Am Emp1 Dec10 8Am File2 Emp1 Dec11 12Pm Emp2 Dec11 2Am Emp1 Dec11 3Am Emp3 Dec11 ...
0
votes
0answers
6 views

Connecting bluetooth with HC06 fails over and over again, although it is visible

For a recent project I try to make a python program that let me connect with the HC06 module. For that I use pybluez. But this wont work at all, so I tried to pair through terminal using bluetoothctl. ...
-1
votes
3answers
28 views

replace multiple strings in a file in python3 [closed]

I have test file where i have some entries like below and i need to change memberUid to nisNetgroupTriple along with the names $ cat testfile2 memberUid: tony memberUid: jacob memberUid: zenny ...
-2
votes
1answer
18 views

Find process source which executing python scripts [closed]

From last month some process is executing python scripts on my server with centos 6 with LAMP stack which are nothing but spam bots and eating server resources. Please check image below, How do I ...
0
votes
1answer
66 views

Cant change python interpreter in Visual Studio Code on Mac

In my console (iterm2) which python gives /Users/anders/anaconda3/bin/python In Visual Studio Code's built in terminal which python gives /usr/bin/python Since I want to use anacondas python ...
0
votes
0answers
14 views

Python Netsnmp and snmpwalk [migrated]

I am trying to use snmpwalk to gain some info and stats on some interfaces. I use this: import netsnmp serv = "172.16.1.1" snmp_pass = "private" oid = netsnmp.VarList('IF-MIB::ifName','IF-MIB::...
1
vote
2answers
46 views

Awk or Sed: If pattern is found: delete line && export variable

In my bashscript I want Sed to find debug: Debug in a file ${SourceP} and if found delete that line and export to the environment Debug=Debug sed -i '/debug: Debug/,+0 d' ${SourceP} && export ...
-2
votes
0answers
15 views

How do you setup atom/terminal on Linux to get python modules working? The terminal is unable to find the modules

I am trying to import requests in atom-runner or running the .py file on terminal, but I get the following error. However, when I import the module in terminal and run the script there is no error at ...
0
votes
1answer
34 views

After installing anaconda-2.5.3 in centos 7 , yum and gnome not working

Normally i do the installation from shell command as shown below.. sh Anaconda2-5.3.0-Linux-x86_64.sh After the installation i realised that some dependencies for the python package yum gone missing....
0
votes
1answer
28 views

Is there a more lightweight solution to read/write MP3 with Linux+Python?

This works very well to export a WAV to MP3: from pydub import AudioSegment song = AudioSegment.from_wav("test.wav") song.export("test.mp3", format="mp3", bitrate="256k") but it requires to install ...
-2
votes
0answers
62 views

bash: /usr/bin/yum: /usr/bin/python3.7: bad interpreter: No such file or directory

my server is CentOS. Linux release 7.4.1708 kernel: 3.10.0-693.el7.x86_64 It is not possible to use yum package manager. Every command (install, remove, search etc.) will produce the error message: ...
0
votes
1answer
28 views

Variable not getting resolved inside $()

I am expecting that variable url will be resolved in $() but I am getting variable of variable as url and not "http://testing.com" url="http://testing.com" echo "Fetching from ${url}" some_var=$(...
0
votes
0answers
11 views

python files list, and add if condition to isolate envi. based on the filename.

We have two files with the below names in the current working directory; logic-dev-east.txt logic-dr-east.txt I want to list files ends with .txt and add an if condition to print a test message ...
0
votes
1answer
39 views

Suspend and then resume a process in python scrip - Linux

I am trying to see if there is a way I can suspend and then resume a process in a python script. I get the process pid using os.getpid() and then i suspend the process using suspend(). Is there a way ...
1
vote
0answers
53 views

Yum not found on Centos 7 “ No module named yum”

I recently installed CentOS 7 but have run into an issue with yum. I get the following error: There was a problem importing one of the Python modules required to run yum. The error leading to this ...
0
votes
0answers
13 views

How to specify the number of processors, in qsub command for SGE:

I have a python file, that I want to execute in SGE. In the beginning I used: qsub main.py Now, I want to specify the number of processors, amount of memory and the max exec time. I followed this ...
0
votes
2answers
89 views

How to convert shell output to JSON?

I have this output in the following and I am trying to convert it to JSON api format. I want to know how can I do it. rock64@rockpro64:~$ sh MACscript.sh eth0 11:1d:11:11:11:1d lo 00:00:00:...
0
votes
3answers
53 views

Stop/kill a process from the command line after a certain amount of time

I have a Python code which listens and detects environmental sounds. It is not my project, I found it on web (SoPaRe). With the ./sopare.py -l command, it starts recording sounds but in infinite loop. ...
1
vote
1answer
23 views

Why did I not install the package version that I expected?

I was looking at Python2.7 for debian jessie since my goal was to downgrade Python 2.7.13 to 2.7.10 or lower (running on OSMC which is now on stretch). From its name it looked like that package was ...
2
votes
0answers
28 views

Create all combinations of 4 elements out of a larger list [migrated]

I want to create all possible combinations of 4 chemical elements out of a list of 9 and use them to create folders named after these combinations. The desired list looks something like this: {Cr, Hf,...
-3
votes
1answer
62 views

Extract data between two patterns from a huge (forced) text file

I have filename.json. If I parse it in terminal with file filename.json output is: filename.json: UTF-8 Unicode text, with very long lines wc -l filename.json 1 filename.json If I parse it ...
0
votes
0answers
19 views

Set multiple python environments in bash_profile

I have two Python (miniconda) environments, one is Python 2 and one is Python 3. The main one I'm using is the Python 3 environment, namely called "py3env". This is in my bash_profile as PATH so when ...
0
votes
1answer
26 views

How to create wrapper script for python so that sys.executable becomes equal to name of this script?

I need to run Python interpreter with custom parameters and custom environment. Let's say I create a bash script which exports required variables and calls /usr/bin/python3 with required parameters. ...
-1
votes
1answer
18 views

Accessing a linux file content through an url

I want to access a Linux file content through an url. When we access the url we can see the content of that file being displayed in the screen. Is there any procedure to do this.
0
votes
0answers
13 views

Can I reschedule a process to real time scheduling?

I'm running some stuff in a python script. At one point there's a few lines of code where I need the timing to be exactly the same every time. The time isn't important - just consistency. ...
1
vote
1answer
32 views

Install python on an embedded device

I'm working on an embedded device already customized. Here some details: # uname -a Linux DX-4400 3.10.31-ltsi-05172-g28bac3e-dirty #12 SMP Tue Jan 23 17:14:13 EST 2018 armv7l GNU/Linux I have root ...
0
votes
1answer
42 views

How to open file in sublime and execute with python using xargs [closed]

I'm trying to open a python script and run it at the same time using xargs. I've tried: subl script.py | xargs python3 And a few other variations but none seem to work. How would you do this using ...
2
votes
1answer
39 views

How can I write directly to a Solaris FIFO pipe over ssh?

I have a Solaris server running a process that has its input and output redirected into FIFO pipes (fifo_in, fifo_out). How can I connect to these two pipes over ssh? I would like to be able to ...
0
votes
0answers
22 views

Linux Mint cannot launch or remove IPython3 through software manager

I tried to launch ipython3 from Software Manager, but got the following errors, There seems to be a programming error in aptdaemon. This is the software that allows you to install/remove software and ...
0
votes
2answers
41 views

automatize partition creation with fdisk

I am using these commands on command line: sudo fdisk /dev/mmcblk1 p d w sudo fdisk /dev/mmcblk1 n (using all defaults) w Please is there any option how to automatize this task? Or how to use one ...
0
votes
0answers
26 views

Not Sleep while script is running

import os import time import random from os import listdir from os.path import isfile, join from random import randint from InstagramAPI import InstagramAPI PhotoPath = "/home/irakli/Desktop/Image" #...
1
vote
2answers
65 views

python-pip : ImportError: cannot import name main

I am using Debian 9.5 Stretch release. I am having import error while using pip. When I try using pip it says: However I can use python: I have two versions of python installed: 2.7 and 3.5 Output ...
0
votes
0answers
30 views

Upgrade uwsgi fails

I encounter the following error when I try to upgrade uWSGI ● uwsgi.service - LSB: Start/stop uWSGI server instance(s) Loaded: loaded (/etc/init.d/uwsgi; bad; vendor preset: enabled) Active: ...
0
votes
2answers
30 views

Can I create my own command in python? [duplicate]

Suppose I have command like cd abc/def, So I want to create own command like 'a'. If I run 'a' command it ,should run command cd abc/def optiplex-3020:~$ a So could it be possible and I want to use ...
0
votes
1answer
34 views

Bash run multiple Python scripts with pre-imported modules

I want to run separately two Python scripts in command line, where the script1.py imports Python modules and the script2.py uses these pre-imported modules to conduct calculations. The reason of doing ...
0
votes
2answers
19 views

Unable to Login to Wok on Fedora Server 27 - Python and PAM

I just setup WOK and can't login via my root uname/pwd. I found a ticket on Github with a "solution" but I have no idea how to implement it. Does anybody have an idea how to translate this into ...
1
vote
3answers
59 views

Find or extract text between two patterns either on the same line or in many lines

I need to print the text between two patterns without keeping in mind their place as they are found randomly across the file. either in the same line or not in the same line or a text occur between ...
2
votes
0answers
31 views

Charm crypto library - unit tests failing with undefined symbol: BN_is_negative

I'm trying to build and test the python Charm crypto library from source. It compiles and installs ok, but I get 91 cases of undefined symbol: BN_is_negative when running sudo make test: /charm/charm/...
-1
votes
1answer
14 views

systemctl zabbix invoke sudo shell command in python scrip

two days ago,I change my running of zabbix-agent from zabbix_agentd run directly to systemctl start zabbix-agent.There is a weired thing.I write a python script to monitor java GC status, which invoke ...
2
votes
1answer
34 views

Python module RPM package Requires section

I am trying to build an RPM package for some Python module (actually its graph-tool: https://git.skewed.de/count0/graph-tool/) The question is: what do I have to put to the Requires section? If I, ...
0
votes
0answers
9 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 ...
1
vote
1answer
91 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 ...
0
votes
1answer
18 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 ...