python

Unable to uninstall virtualenv from debian 11

Unable to uninstall virtualenv from debian 11 My debian OS has been through a few upgrades and is now on 11 (Bullseye). I initially started out with python2 and now I no longer want it – I just want python3. I installed virtualenv a long while back when I was still working with python2. I …

Total answers: 1

How do I install a pip package on a machine without Internet access?

How do I install a pip package on a machine without Internet access? I’m working on a Linux machine without (direct) Internet access. I want to pip install foo for some pypi package foo, but – obviously, that won’t work. I have, of course, other machines which are connected the Internet. How would I go …

Total answers: 1

How to install Python3.12 on ubuntu?

How to install Python 3.12 on Ubuntu 23.10? I did several wrong things for my first day on Ubuntu when trying to code with Python, so I just reinstalled it. Can anyone tell me the best way to install Python here? I am using Ubuntu 20.04, and I am updating to Ubuntu 23.10 right now. …

Total answers: 1

send notification from one systemd unit to another with python?

send notification from one systemd unit to another with python? I have a systemd unit ‘my-app’ that runs my main python app but I want it to auto-update when there is a new version on a remote server. The detection is watched by another python systemd unit (let’s call it "watch-app") on the same OS …

Total answers: 1

Run shellcode as root in a buffer overflow attack?

Run shellcode as root in a buffer overflow attack? I’m trying to exploit the following code: #include <stdio.h> #include <string.h> int main(int argc, char** argv){ char buffer[100]; strcpy(buffer, argv[1]); return 0; } with the following command ./vuln $(python -c "import sys; sys.stdout.buffer.write(b’x90’*60 + b’x31xc0x50x68x2fx2fx73x68x68x2fx62x69x6ex89xe3x89xc1x89xc2xb0x0bxcdx80x31xc0x40xcdx80′ + b’x40xd6xffxff’*6)") The first part is the NOPs, the second part …

Total answers: 2

Fetch data from a large file based on time and date recursively

Fetch data from a large file based on time and date recursively Fetch data based on date(column 1) and time (column 2). Each date has time in column 2. Based on each date in column1 two files are to be generated which will have all the fields based on time 6:00 to 21:50:08 (day) and …

Total answers: 3

Cron, python and saving to a file

Cron, python and saving to a file I’ve got a veeery simple script written in python that tests my internet connection na saves parsed data to a json file: #!/usr/bin/python3 import subprocess, json, os from datetime import datetime # run the bash script and parse results def speedtest(): result = subprocess.run(["/bin/speedtest-cli", "–simple"], stdout=subprocess.PIPE, encoding="UTF-8").stdout # …

Total answers: 2

How to read and restore the last megabyte of a drive using Python

How to read and restore the last megabyte of a drive using Python I’m writing some code to do backups of my hard drives, using Python 3. My issue is that some RAIDs and other things hide stuff in the first and/or last megabyte of some drives. I want to make sure I copy and …

Total answers: 1

Is it possible to install and use the concurrent.futures module?

Is it possible to install and use the concurrent.futures module? I’m reading Python documentation at https://docs.python.org/3/library/concurrent.futures.html and I want to use this feature, but I cannot. It fails on the first step: importing the module. For import concurrent.futures I get File "<stdin>", line 1, in <module> File "/home/kevin/concurrent.py", line 3, in <module> import concurrent.futures ModuleNotFoundError: …

Total answers: 2

Kill process on broken pipe from within a bash script

Kill process on broken pipe from within a bash script Consider the code: printf ‘%sn’ 1 2 3 4 5 | head -n 2 which has the output: 1 2 My understanding is that when the head process breaks the pipe after reading the two first lines then the printf process catches the broken pipe …

Total answers: 1

Apache shows Python code instead of execute it

Apache shows Python code instead of execute it VPS server running Ubuntu 22.04, Apache 2.4.18 and Python 3.5.2 When I try to access a webpage on that server it shows python code instead of execute it… Last guide I tried was this: https://howtoforge.es/como-ejecutar-scripts-de-python-con-apache-y-mod-wsgi-en-ubuntu-20-04/ But the problem still remains. Asked By: Art || Source Install wsgi …

Total answers: 1

Failing to install PyPi package gdown via py2dsp

Failing to install PyPi package gdown via py2dsp On Debian-like/apt-based distributions, instead of installing Python packaged system-wide with pip install –system, we use APT packages. Here: Install a Python package on Debian/Devuan when apt has no package for it is a discussion on how to do that. Unfortunately, this fails when I try it with …

Total answers: 1

Install a Python package on Debian/Devuan when apt has no package for it

Install a Python package on Debian/Devuan when apt has no package for it I want to install some Python package pandasql system-wide, on a Devuan (or Debian) system. It’s in the Python Package Index, but – there doesn’t seem to be a (dpkg) package for it; let’s assume that there actually isn’t. Now, if I …

Total answers: 2

How can i open the __init__.py file to edit it?

How can i open the __init__.py file to edit it? I have been advised elsewhen on this forum that to correct an issue (with connection to Tor-Browser) I can "fix this by going into the init.py file and changing the lines (98) in /usr/lib/python3/dist-packages/torbrowser_launcher/: " HOWEVER, I am 74 years old and not tech-savy. Is there a kind soul …

Total answers: 1

Unable to install mysqlclient on Ubuntu 22.04.3

Unable to install mysqlclient on Ubuntu 22.04.3 I want to install MySQL on my Ubuntu 22.04.3 for a Django course I’m taking. I used the following command: pip install mysqlclient I tried the suggestions in this thread: Unable to install mysqlclient on Ubuntu 20.10 I followed the steps mentioned but didn’t resolve it. Step 1 …

Total answers: 1

Nesting quotes in shell

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 (most recent call last): File "<string>", line 1, in <module> NameError: name ‘MysString’ is not defined I understand that when I …

Total answers: 2

Moving 3 pics randomly to another directory

Moving 3 pics randomly to another directory I am using Linux and I’m in a folder it has 10 .jpg images I want to move 3 pictures only without selection by name or size for example my folder is /sdcard /DCIM/camera/ I want 3 pictures from it to /sdcard using a Linux command it’s possible? …

Total answers: 1

Remove duplicates by adding numerical suffix

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 + ${x:01} Input file tag:20230901-FAT val:1034 tag:20230901-FAT val:1500 tag:20230901-LAX val:8934 tag:20230901-SMF val:2954 tag:20230901-LAX val:1000 tag:20230901-FAT val:1500 Desired output tag:20230901-FAT-02 val:1034 tag:20230901-FAT-01 val:1500 tag:20230901-LAX-01 …

Total answers: 4