New answers tagged

0

PIP community discontinued the support to 2.7. You will have to upgrade pip to latest version. pip install -upgrade pip


0

Here's a quick hack you can use in an emergency: sed -i 1s/python/python2/ /bin/yum I wouldn't use it as a solution - it creates inconsistency and also only fixes yum. There may well be other system or other tools that depend on pythin2. Just my 0.02.


0

Use: /opt/python-3.6/bin/pip3 install pyqt5 This is the way to install any Python package listed on PyPI.org. Each specific Python interpreter installation has its own independent world of packages. The pyqt5 you installed via apt is only built and installed for use with the OS distro's python3 interpreter. For things that need to be compiled, that may ...


0

I know that it might sound totally unrelated but I've recently had a similar issue. Thing is, I'm on Linux and can't check on Mac. Bash defaults changed in 5.1, that was the root cause. In my case the text was also pasted 'highlighted' when I pasted it in regular shell, and it turned out that setting enable-bracketed-paste off helped - not only with the ...


3

The python open() function has two parameters, the first is the file to be opened and the second is the mode in which to open it. For mode you have the following options: A string, define which mode you want to open the file in: "r" - Read - Default value. Opens a file for reading, error if the file does not exist "a" - Append - Opens ...


4

A systemd unit with Type=simple is expected to not fork into the background, but screen -d -m creates a new detached session in the background and exits. This causes systemd to regard the unit as dead and either kill the detached session or lose track of it. Use -D -m instead: Type=simple ExecStart=/usr/bin/screen -D -m … The difference between those two ...


3

With GNU awk to manage large numbers of open files if you have more than about 15 columns (or any awk if fewer than that): $ cat tst.awk BEGIN { FS="," } NR==1 { for (i=1; i<=NF; i++) { out[i] = $i ".txt" } next } { for (i=1; i<=NF; i++) { print $i > out[i] } } $ awk -f tst.awk list.csv $ ...


1

With awk: awk 'NR == FNR { if(hdr){ hold[hdr]=$0; hdr="" }; if(/^>/) hdr=$0; next } ($0 in hold){ print $0 ORS hold[$0]; getline; next } { print }' file2 file1


0

Or with bash and cut and tr #!/bin/bash id=0 while read filename; do id=$((id+1)) tail -n +2 list | cut -d"," -f $id >> "$filename" done < <(head -1 list.csv | tr "," "\n")


-1

Can use a combination of bash with awk: for n in 1 2 3; do awk -F "," "{if (NR!=1) {print \$$n}}" list.scv > $(awk -F "," "{if (NR==1) {print \$$n}}" list.scv) ; done Example:


3

awk -F, 'NR==1{ split($0, tmp, ","); next } { for(col=1; col<=NF; col++){ print $col >>tmp[col]; close(tmp[col])} }' infile In NR==1{ split($0, tmp, ","); next }; where NR in awk represent the total Number of Records read/seen so far; so for the first line NR would be 1 and we are checking it with NR==1, if it's ...


0

Maybe this is a detour but I did: Login the node Include in myscript.py: #!/anaconda3path/bin/python3.6 Run as: nohup python3.6 myprogram.py > NNp.out & Problem solved!


2

You can't have two stdin's - how would python know where the code stops and the content starts? Here is a workaround by using Process Substitution: echo values | python3 <(cat <<SCRIPT with open('/dev/stdin') as f: print(f.read()) # -> "values" SCRIPT )


-1

For example, you can do: os.system("ping 1.1.1.1 >> ping.txt") with open("ping.txt", "r") as ping: print(ping.read())


2

How can I prevent myself from setting default Python version to Python-3 in the future Remove python versions from update-alternatives: sudo update-alternatives --remove-all python In the future the following command sudo update-alternatives --config python will show you: update-alternatives: error: no alternatives for python3


1

Run it as a service. Create /etc/systemd/system/myscript.service: [Unit] Description=My Script [Service] ExecStart=/usr/bin/python3 /path/script.py [Install] WantedBy=multi-user.target Then run it with: sudo systemctl start myscript # Runs the script now sudo systemctl enable myscript # Sets the script to run every boot There are lots of other ...


0

There are multiple ways to do this based on your needs and conditions such as user privileges and the order of execution whether it should wait for other services to start or not. the easiest ones are : crontab can be used like the following: #crontab -e @reboot python /path/your_script.py & Or you can mention the the command in /etc/rc.local this ...


1

I am also a hobbyist, but some things you can try to look at is the documentation for the type of lockscreen manager you have, I.E SDDM (Typical with KDE) and poke around their Settings. KDE offers an array of API Calls in their engine to interact with these components, A good base point is the Arch wiki's (Even if you don't use arch, they have some of the ...


0

In my case (RHEL7.8 + Apache 2.4 + Shibboleth 3.2) I was able to resolve the issue by replacing the /usr/lib64/libldap_r-2.4.so.2 library with the one from the Apache directory: <APACHE_ROOT>/HTTPServer/openldap/lib/libldap_r-2.4.so.2 Run: locate libldap_r-2.4.so.2 to find the location of the library. In my case I got: /app/ptc/Windchill_12.0/...


-1

I was getting error for writing: python script.py solution: change python to python3 python3 script.py (this may work for ubuntu users)


2

CentOS 8 uses dnf now instead of yum, but that is not your issue. You are using an underscore (_) when you wanted to use a hyphen (-). dnf install python2-devel The release package for the okay repository seems to be located here (there is no okay-release-1-1.noarch.rpm, I only saw okay-release-1-2.noarch.rpm and okay-release-1-3.noarch.rpm)


0

Oh no, we almost forgot netcat! If there is netcat (any version) on your jump host, you can use it instead of ProxyJump in your config generally like: ProxyCommand=ssh -T user1@gateway "exec nc %h %p" Or from the command line: ssh user2@devbox -oPorxyCommand="ssh -T user1@gateway 'exec nc devbox 22'"


0

First, I suggest using a terminal which is not dependent on python. gnome-terminal or xterm would work: $ file $(which terminator) $(which xterm) $(which gnome-terminal) /usr/bin/terminator: Python script, ASCII text executable /usr/bin/xterm: ELF 64-bit LSB pie executable, ... /usr/bin/gnome-terminal: ELF 64-bit LSB pie executable, ... While ...


-1

An alias alone might not be enough. Sure you can create one in your .profile and source that before your shell starts but some applications/dependencies my still find 2.7 as your default. This is because of the symlink found in usr/bin. Create a new one in that location and point it to the interpreter you wish to use.


0

After countless tries I finally solved the problem that was driving me crazy. Since it arose with an apparently faulty installation of Python 3 , I tried to reinstall it but it was no possible due to errors with apt-get or corrupted python packages. I followed the steps of a post and a related question but python3 installation failed again, although the ...


0

When I worked with a company that had this kind of requirement they were interested in more like 100 years. To be honest by the difference between 50 and 100 years doesn't seem that much. Any bets on the what the future will look like are going to be wrong. So I'd be very skeptical about any advice telling you this or that will still be around. The ...


-2

count=`awk 'END{print NR}' filename` for ((i=1;i<=$count;i++)); do j=$(($i+1)); m=`awk -F "|" -v i="$i" 'NR==i{k=substr($4,1,8);print k"_"$5}' filename`; echo $m >"$m.fasta";echo -e "\n" >> "$m.fasta" ;awk -v j="$j" 'NR==j {print $0}' filename >> "$m.fasta";i=$...


1

Run programX.py as a separate functional user account and group. This will cause all files created by that program to be owned by the functional account. Set the umask in the functional accounts profile to 0077. This will limit access to the files to the functional account only. From there, within programX.py you can set the mode of the file you wish to ...


1

A non awk solution, assuming, given the example, that the file must be splited every 2 lines: # split the file every 2 lines and save in files prefixed FOO. split -l2 131751_pphA.fasta FOO. # loop over the files for f in FOO.*; do # `awk` and `sed` to get the pattern to use as file name and first line, i.e "PANS_1_2_pphA" n=$(awk -F'|' '{ ...


2

awk -F'|' ' NR%2{ close(fileName); hdr=$4""$5; sub("annot.gbk", "", hdr); fileName=hdr".fasta"; print ">"hdr >fileName; next; }; { print >fileName; }' infile


0

I encountered same issue converting list to json solved this for me. import subprocess cmd = """gunicorn 'myapp:create(json.dumps([{key: ""}]))' --worker-class gevent -w 1 --bind 127.0.0.1:8019""" subprocess.call([cmd], shell=True)


0

Although it's not generally recommended, here's a shell loop to solve the issue: while IFS='=' read -r key value; do case $key in (*_file_name) value=$( basename "$value" ); esac printf '%s=%s\n' "$key" "$value" done <file For each line in the file called file, this reads the bit before the = into the key variable, ...


0

Doesn't look like you need a shell for this. Try cmd = ["gunicorn", 'myapp:create([{key: ""}])', "--worker-class", "gevent", "-w", "1", "--bind", "127.0.0.1:8019"] subprocess.call(cmd, shell=False)


1

Creating a Docker image and running it is one option as you have mentioned. However, a more simple approach on *nix systems could be to use the supervisord to run the service. Not only python, I have run all sorts of perl, shell and ruby scripts under supervisord. I have even run Flask applications under supervisord without the need for dockerizing those ...


3

With awk you can print two fields, first and last in this case, when the line has {MY_DIR} if previously you set FS as [/=]. $ awk -v FS='[/=]' -v OFS='=' '/{MY_DIR}/ {print $1, $NF;next} 1' file > outputfile input0_bpp=8 input0_is_padding_enable=0 input0_task0_file_name=cam_1024x512.bin output0_bpp=8 output0_is_padding_enable=0 output0_task0_file_name=...


4

It seems you just need to get rid of the filepath. sed -e 's,file_name=.*/,file_name=,' < file > newfile should do the trick... it takes, on each line containing file_name=.../..., the whole portion between the = and the last / out of the line. If you want to edit "in place", and use GNU sed, you can: sed -i -e 's,file_name=.*/,file_name=,' ...


1

Leaflet is imported form the Handy module belonging to gi/respository. set_mode_transition_type is deprecated for Leaflet since version 0.0.12 according to https://valadoc.org/libhandy-0.0/Hdy.Leaflet.set_mode_transition_type.html Try updating gtweak or downgrading Gi library. A not so recommended workaround would be to change set_mode_transition_type to ...


0

I installed https://github.com/EscVM/OIDv4_ToolKit following their instructions in a clean centos8 docker image. I needed python-devel, gcc, make, cmake and the "development tools" bundle that was suggested at some point. Not QT. Then I was able to run the python3 main.py -h command successfully. Most likely you installed inappropriate package(s) ...


0

As far as I can tell distutils is part of Python standard library, at least for Python 3. If you don't have it installed you must then have a botched Python installation (perhaps intentionally so by the hosting provider). Regardless, the source for distutils can be found here. You only need to get a copy of it on the affected system (either via git clone or ...


-1

I had the same annoyance of lots of files in my home directory. This is what I did. Create a directory ~/+Files. Move all of my(not the annoying config files) files to this new directory. Configure interactive shell, and dolphin to start in this new directory. Create a directory for config files ~/+Files/config Move config files to this new directory, and ...


Top 50 recent answers are included