<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>python on Notities</title><link>https://www.vandenboom.icu/en/tags/python/</link><description>Recent content in python on Notities</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Wed, 03 Apr 2024 20:20:39 +0000</lastBuildDate><atom:link href="https://www.vandenboom.icu/en/tags/python/index.xml" rel="self" type="application/rss+xml"/><item><title>SSH in remote machine with SSH keys and run command in new Python 3</title><link>https://www.vandenboom.icu/en/blog/2024-ssh-in-remote-machine-with-ssh-keys-and-run-command-in-new-python-3/</link><pubDate>Wed, 03 Apr 2024 20:20:39 +0000</pubDate><guid>https://www.vandenboom.icu/en/blog/2024-ssh-in-remote-machine-with-ssh-keys-and-run-command-in-new-python-3/</guid><description>T﻿o make a script to run remote commands in a client server network.
import subprocess def ssh_exec_command(hostname, username, command): ssh_cmd = ['ssh', f'{username}@{hostname}', command] ssh_process = subprocess.Popen( ssh_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True ) output, error = ssh_process.communicate() if error: print(&amp;quot;Error:&amp;quot;, error) else: print(&amp;quot;Output:&amp;quot;, output) # Replace these with your actual credentials and command hostname = 'remote_host_address' username = 'your_username' command = 'ls -l' ssh_exec_command(hostname, username, command)</description></item><item><title>SSH in remote machine with SSH keys and run command in old Python 2</title><link>https://www.vandenboom.icu/en/blog/2024-ssh-in-remote-machine-with-ssh-keys-and-run-command-in-old-python/</link><pubDate>Wed, 03 Apr 2024 20:12:58 +0000</pubDate><guid>https://www.vandenboom.icu/en/blog/2024-ssh-in-remote-machine-with-ssh-keys-and-run-command-in-old-python/</guid><description>I﻿n case you have an old legacy system with Python 2 still in use and want to make a script to run certain commands in a client server network.
import subprocess def ssh_exec_command(hostname, username, private_key_path, command): ssh_cmd = ['ssh', '-i', private_key_path, '-o', 'StrictHostKeyChecking=no', f'{username}@{hostname}', command] ssh_process = subprocess.Popen( ssh_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) output, error = ssh_process.communicate() if error: print(&amp;quot;Error:&amp;quot;, error) else: print(&amp;quot;Output:&amp;quot;, output) # Replace these with your actual credentials and command hostname = 'remote_host_address' username = 'your_username' private_key_path = '/path/to/your/private_key' command = 'ls -l' ssh_exec_command(hostname, username, private_key_path, command)</description></item><item><title>Prevent opening Windows 11 Store when typing the command python</title><link>https://www.vandenboom.icu/en/blog/2022-prevent-opening-windows-11-store-when-typing-the-command-python/</link><pubDate>Thu, 01 Dec 2022 19:30:38 +0000</pubDate><guid>https://www.vandenboom.icu/en/blog/2022-prevent-opening-windows-11-store-when-typing-the-command-python/</guid><description>Step 1: Open Settings in Windows 11
Step 2: Go to Apps
Step 3: Go to Advanced app settings
Step 4: Go to App execution aliases
Step 5: Disable the option for python.exe and python3.exe</description></item><item><title>Python dependencies when installing Oracle VirtualBox on Windows 11</title><link>https://www.vandenboom.icu/en/blog/2022-dependencies-van-python-bij-de-installatie-van-oracle-virtualbox-op-windows-11/</link><pubDate>Thu, 01 Dec 2022 19:24:55 +0000</pubDate><guid>https://www.vandenboom.icu/en/blog/2022-dependencies-van-python-bij-de-installatie-van-oracle-virtualbox-op-windows-11/</guid><description>Step 1: install Python
Step 2: add both the scripts folder and its parent folder to the path
Step 3: CMD&amp;gt; pip install pywin32</description></item><item><title>Set the Python interpreter version for the extension: Code Runner in VSCodium</title><link>https://www.vandenboom.icu/en/blog/2022-stel-de-versie-van-de-python-interpreter-in-voor-de-extensie-code-runner-in-vscodium/</link><pubDate>Sun, 03 Apr 2022 19:55:44 +0000</pubDate><guid>https://www.vandenboom.icu/en/blog/2022-stel-de-versie-van-de-python-interpreter-in-voor-de-extensie-code-runner-in-vscodium/</guid><description># File name: version_used.py # This prints the version of Python being used by the Code Runner extension in VSCodium # Set by going to: File -&amp;gt; Preferences -&amp;gt; Settings -&amp;gt; Search Settings -&amp;gt; code-runner.executorMap -&amp;gt; Edit in settings.json # &amp;#34;python&amp;#34;: &amp;#34;/bin/python3.9 -u&amp;#34;, # To run this script press the little play button on the top right in the editor import sys print(sys.version)</description></item><item><title>Install Python 3.9 on Ubuntu Linux</title><link>https://www.vandenboom.icu/en/blog/2022-installeer-python-3-9-op-ubuntu-linux/</link><pubDate>Sun, 03 Apr 2022 18:55:18 +0000</pubDate><guid>https://www.vandenboom.icu/en/blog/2022-installeer-python-3-9-op-ubuntu-linux/</guid><description>$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
$ sudo apt install python3.9
$ python3.9 &amp;ndash;version</description></item></channel></rss>