Questions tagged [python]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
150 views

Multiple replacements using regular expressions in python

Can I use regex in python to have multiple types of substitutions? Like in this string "hello, this is me" I want to replace 'hello' with 'hi' and 'this' with 'its'. Can I do it in a single line? Or ...
0
votes
2answers
34 views

extracting string from files and merge (python)

I have a directory with multiple subfolders that all contain several text files which are formatted in the following way. data01:data02 I need to extract just the data02 after the : and export this ...
0
votes
0answers
160 views

hp-plugin install issue so I cannot scan

running Ubuntu 18.04 and printing well using my HP printer I have an issue with the scan. I can connect to my scanner (using Simple Scan or xsane), however, that's all. Error shows up saying I have ...
1
vote
2answers
118 views

Is it safe to add new python version to PATH?

Is there any danger to adding a new version of python to PATH? i.e. will some important system programs break? Suppose this is without deleting the old python2, but effectively changing the command "...
4
votes
1answer
264 views

is 'sed' thread safe

If I have a shell/python script that uses sed to modify a file in place based on user inputs, and then two users run the same script at the same time or approx. same time, is 'sed' thread safe ? Or ...
0
votes
1answer
1k views

pip install error: “SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed”

I am getting the following error when I try to do anything in pip. I have tired to upgrade pip as stated below and nothing. Any ideas? Collecting pip Exception: Traceback (most recent call last): ...
0
votes
1answer
103 views

sudo: move: command not found [closed]

I wanted to automate installation of pycharm on my new Linux Mint 19.1 and everything works great until I use sudo move command. Whenever code goes to that line I get "sudo: move: command not found" ...
5
votes
3answers
1k views

Equivalent to “source” in OpenBSD?

Trying to open a python3 virtual environment I have created with python3 -m venv myVenv by doing source myVenv/bin/activate as I do in Linux, but I get ksh: source: not found which mean it is ...
2
votes
1answer
653 views

Installing python modules fail - “limits.h” missing?

I am trying to install a number of python 3 modules (e.g. regex, cytoolsz, spacy) that require compilation, but they all fail with an error identical to the below (bottom). I have tried to check for ...
0
votes
0answers
43 views

How do I get CRON to run a script that works in my regular shell, but not in CRON? [duplicate]

I am running Ubuntu 18.04 LTS on an Amazon LightSail instance. When I try to run a Python script as soon as I log, it runs perfectly. I run my script with the full path in with the command: /usr/bin/...
-1
votes
2answers
254 views

Using filter condition in python -mjson.tool command

Can I use a filter condition in python -mjson.tool command to select objects which has specific attributes? For example, I have a sample.json file with for objects out of which two has an attribute "...
1
vote
1answer
404 views

All debian main commands broken by glibc

Here is the thing. I'm lost. I downgraded from Debian 10 buster (testing) to Debian 9 stretch (stable) by editing the /etc/apt/sources.list file. I typed : apt-get update apt-get upgrade apt-get ...
0
votes
0answers
55 views

How do I save the putty screen with python?

i write sth on putty screen with python. But i can not save this screen. i have opened putty (logging >> log file name). Then i start the python. after python finnish. then i can open this putty ...
1
vote
2answers
142 views

How convert bash output to JSON with key {#PROCNAME}?

I try get JSON with top 5 process by memory. This JSON i want send to Zabbix and draw top 5 process by memory. I get top 5 process by memory by command: ps axho comm --sort -rss | head -5 node ...
0
votes
0answers
24 views

How to understand some specific file directory paths with the cffi warning/errors?

The module cffi-1.7.0 and python-magic-5.11 should be installed normally, but when executing the python-magic built-in example.py, it failed! Now we just wonder the following two questions: 1) Why ...
0
votes
1answer
332 views

tkinter error when trying to import matplotlib.pyplot in Arch Linux

I'm using Arch Linux with Gnome. I used pip to install matplotlib in my home directory: pip install --user matplotlib This seemed to work, and when I use Python I can successfully import matplotlib. ...
1
vote
1answer
134 views

Optimal sharing of a ring buffer between processes

We're implementing an embedded Linux system and have to provide a live updating graph on a website that shows data coming from a background process in the system. The question is how to optimally ...
0
votes
1answer
22 views

RHEL upload / pull scripts from people without access to the server itseld

I have a RHEL Server and would like to enable a group of users to be able to upload / modify mostly Python script that enrich data in our ticketing system. The problem is that they can't have access ...
1
vote
1answer
506 views

No module named yum CentOS6

I think I messed up my python config now yum wont work. I'm getting error 'No module named yum'. I have tried editing /usr/bin/yum and adding #!/usr/bin/python2.6 as the interpreter but this has not ...
0
votes
2answers
919 views

How do I install pip on CentOS?

I'm using CentOS 7. I want to use Pip to install a virtualenv . So I installed Pip like so ... [laredotornado@server Python-3.7.2]$ sudo yum install python-pip httpd mod_wsgi [sudo] password for ...
0
votes
2answers
286 views

How to create a shell dictionary from an output of a python script?

My python scripy print a string by print("declare -A gaps=( [2019-2-24]=4 )") and I can run declare -A gaps=( [2019-2-24]=4 ) on a bash shell to create a dictionary named gaps. In my bash script, I ...
0
votes
1answer
46 views

Trying to save a photo with python, but when I execute the program with the terminal, It returns that there is no such directory [closed]

I have been trying to execute this program: 1 import PIL as pillow 2 from PIL import Image, ImageFilter 3 photo = Image.open("index.jpeg") 4 b = photo.filter(ImageFilter.BLUR) 5 b.save("/home/...
1
vote
2answers
88 views

How can I extract only the pid column and only the pathname column in the lsof output?

$ sudo lsof -u t | grep -i "\.pdf" evince 1788 t 37r REG 8,4 176328 134478 /home/t/some/path1/white space/string1 + string2 string3.pdf evince 3737 t 36r ...
0
votes
0answers
35 views

Best way to get rid import error in `vim-latexsuite`

I'm running Arch Linux and I have the vim-latexsuite package installed. A while ago I noticed started getting an error whenever I opened a .tex file: Traceback (most recent call last): File "<...
1
vote
3answers
48 views

How do I control which command is when i type python in the shell

I use anaconda as a way to handle virtual environments. This means I have multiple version of python installed. I experience that the wrong python version starts when I run python from the shell. ...
1
vote
0answers
210 views

Compiling python with custom library path [duplicate]

I'm trying to install the latest Python version on my workstation at work. Unfortunately I don't have root access, and they won't do it for me, so I have to compile from source and put it in ~/local/...
0
votes
1answer
30 views

want to install PyQt5 for slitaz

I want to run an application that need python3 and pyqt5 in Slitaz 5. I am not pro in linux but managed to compile and install python3. now when I try to run application it tell me that need pyqt5. so ...
1
vote
1answer
310 views

How do I properly change the debian default python 2.7.9 to python3 or another version? [duplicate]

what is best-practice for changing the default global python interpreter on my fresh debian-based linux node to python3.x? When I create a fresh Debian or Ubuntu VM, one of the first things I do is ...
0
votes
2answers
33 views

How can I make python detect missing packages or apps [closed]

I'm making a script for Ethical Hacking purposes and I want to have a first function that detects and shows the user what packages they need to install before they can continue. For example, I would ...
0
votes
1answer
213 views

python -c “print calculation” gives syntax error

I was doing some bash scripting and adding some python for float calculations like divide, deductions When I am executing this, all part is running fine but for some python part it is showing me an ...
2
votes
2answers
69 views

Solaris : Sort numerical values

I have a file with following values. keyword1 19.02 1.69.94 keyword2 19.01 1.68.118 keyword3 19.02 1.69.119 keyword4 19.01 1.68.115 keyword5 19.02 1.69.304 keyword6 19.02 1.69.39 I want these to be ...
1
vote
1answer
57 views

Parent process blocking trying to read output from zombie child process

The setup: I have a python (3.6) script (call it "operator") that executes a bash script (call it "plunger") in standard subprocess ways, collecting and logging stdout from the child. The plunger ...
1
vote
1answer
41 views

Compare two text files, extract matching rows of file2 plus additional rows

have been mocking around with this too long and tried grep, join, awk but I cant get the parameters right. I need to get the command right. I have got two text files. cat file1 @ABC:11:ABC:1:...
0
votes
0answers
24 views

Killing a thread in Python (which is descendant of current process) [duplicate]

Normally, Linux threads cannot be killed outside the main proces's scope, except by killing the main process itself, however, I need to do so. I made a threaded program which needs to have a complete ...
0
votes
1answer
21 views

python Ovirtsdk api, how to start a vm in paued mode

I am trying to start a vm in paused mode, but running into issues. I'm able to connect to the API and start vms normally, but I cannot seem to get the params part right for staring paused. In this ...
2
votes
3answers
98 views

Extract every 2 lines from a 40 lines file and create a new file

I have a file with 40 lines like this: 0001.Group admin_group 0001.Users adam, sam, paul, david, jennifer, harry 0002.Group Dev_group 0002.Users mike, pauli, gary, sherry 0003.Group ...
3
votes
0answers
59 views

In Linux, is there a way to automatically mount a drive when it is inserted? [closed]

I'm trying to automatically mount a drive when a user inputs it and show the progress on my web page so I will be translating this into my python code. Using Linux commands - What would you have to ...
3
votes
1answer
124 views

Unable to initialize environment variables on startup

I have written a python script that runs successfully on raspberry pi if it is run manually from the console. As I want to start the script on reboot, I've written a bash script to change directory, ...
0
votes
1answer
449 views

How can I run the sudo command in Python code under CentOS in Docker

I am trying to access the docker image labels from Python as follows hostname = socket.gethostname() cmd = "sudo curl --unix-socket /var/run/docker.sock http:/containers/" + hostname + "/json" output ...
1
vote
2answers
111 views

Different order for getsockopt SO_PEERCRED in Linux and OpenBSD

I'm trying to get the Unix socket peer credentials in python. I am using this piece of code for that: peercred = conn.getsockopt(socket.SOL_SOCKET, socket.SO_PEERCRED, struct.calcsize("3i")) pid, ...
1
vote
1answer
3k views

How to make python3.7 default

I have installed python3.7 however I am not sure how to make it the default python. See below: ~/Documents/robosuite$ python3.7 Python 3.7.1 (default, Oct 22 2018, 11:21:55) [GCC 8.2.0] on linux ...
1
vote
0answers
66 views

Running python commands in a py/text file in Linux terminal using flask shell

Is it possible to run a python file using flask shell similar to python? Similar to: flask shell myfile.py flask shell -f myfile.py That's all I get when using $ flask shell --help: Usage: flask ...
1
vote
1answer
46 views

Is there a fast tool to show all the unique unicode characters in a file and their count?

Does anybody know a tool to tabulate all the unique unicode characters and their counts in a file?
0
votes
0answers
654 views

how to install pip for python 2.7?

I followed the link @https://linuxize.com/post/how-to-install-pip-on-centos-7/#2-install-pip to install pip ,however its intalled for python 2.6 that comes with the system,how do I install it for ...
0
votes
1answer
54 views

Python project not able to find file [closed]

I'm working with a python file that requires two pictures as an input and returns another picture which is the result of the first two. Using the terminal you are supposed to input the file path to ...
0
votes
0answers
47 views

Changing permissions in a Unix directory

I am not able to change permission on a directory I created on the Unix server. This is how the structure looks $ ls engany N832342 N854431 zabbix $ Now I want to change the permission in ...
0
votes
0answers
28 views

Filter output / print one record per event or time period

I've got a custom HID device which prints out exact coordinates of touched points at real time. It is very sensitive & currently printing out the coordinate that's being touched on multiple ...
0
votes
4answers
67 views

Get the command that generated piped data

I'd like to figure out a way to access a string describing the command that was run before the current command running. For example, if I run: ls | myscripthere I'd like to be able to know that the ...
1
vote
2answers
49 views

Speeding up repeated python calls (or, alternatively, porting a complex regex to sed)

I am an academic medical physicist. I do experiments that generate a fair amount of data, and they are expensive to run. My university has a backup system that consists of a robot tape library in a ...
0
votes
1answer
24 views

how to concatenate all lines in file that start with //! to make them into one line in python

so the file looks like this void funct_example ( int stamo) { //! ID{SWERT- 12345} this is function that is suppose to take //! IDREF{SYA-dfjk} return(stamo) } void funcert (string ...