Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts
Tuesday, August 15, 2023
Friday, July 22, 2022
Python: Convert string to and from base64 format
Python: Convert string to and from base64 format
Base64 encoding is a format that can be used for data transfer in HTML or general data representation as you don't need to escape it. To convert a stream of byte object to base64 and vice versa, use the following example.Monday, July 18, 2022
Sunday, January 19, 2020
Installing Kivy 1.11.1 on MX Linux 19 - faster method
MX Linux 19 is the most downloaded distribution as per DistroWatch as of Jan 19, 2020. Since MX Linux is based of Debian, this quick how to should apply to Debian/Ubuntu derivatives as well.
Kivy is an open source cross platform Python library for rapid application development. Kivy generated applications run on Linux, Windows, OSX, Android, iOS and Raspberry Pi.
To install Kivy on MX Linux 19 (and other Debian derivatives), do install Python packages Pip and Venv, like:
Create virtual environment, install Python library dependencies and then install Kivy, like:
This installation method should be faster vs this one.
Kivy is an open source cross platform Python library for rapid application development. Kivy generated applications run on Linux, Windows, OSX, Android, iOS and Raspberry Pi.
To install Kivy on MX Linux 19 (and other Debian derivatives), do install Python packages Pip and Venv, like:
$: sudo apt -y install python3-pip $: sudo apt -y install python3-venv
Create virtual environment, install Python library dependencies and then install Kivy, like:
$: python3 -m venv ~/kivy_venv $: source ~/kivy_venv/bin/activate $: pip3 install --upgrade --user pip $: pip3 install wheel $: pip3 install -U --force-reinstall Cython==0.29.9 $: mkdir ~/tmp $: cd ~/tmp $: wget https://files.pythonhosted.org/packages/aa/20/8d5553d7bb57dfae0ac9c1a68532f8cbdb017baee154f649b90ee012317b/Kivy-1.11.1-cp37-cp37m-manylinux2010_x86_64.whl #below is very important, otherwise pip3 install *whl will not work $: mv Kivy-1.11.1-cp37-cp37m-manylinux2010_x86_64.whl Kivy-1.11.1-cp37-cp37m-linux_x86_64.whl $: pip3 install Kivy-1.11.1-cp37-cp37m-linux_x86_64.whl
This installation method should be faster vs this one.
Installing Kivy 1.11.1 on MX Linux 19
MX Linux 19 is the most downloaded distribution as per DistroWatch as of Jan 19, 2020. Since MX Linux is based of Debian, this quick how to should apply to Debian/Ubuntu derivatives as well.
Kivy is an open source cross platform Python library for rapid application development. Kivy generated applications run on Linux, Windows, OSX, Android, iOS and Raspberry Pi.
To install Kivy on MX Linux 19 (and other Debian derivatives), do install library dependencies, like:
Create virtual environment, install Python library dependencies and then install Kivy, like:
This can take a while, so relax and enjoy!
Kivy is an open source cross platform Python library for rapid application development. Kivy generated applications run on Linux, Windows, OSX, Android, iOS and Raspberry Pi.
To install Kivy on MX Linux 19 (and other Debian derivatives), do install library dependencies, like:
$: sudo apt -y install python3-pip python3-dev libgstreamer1.0-dev libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libpango1.0-dev python3-venv
Create virtual environment, install Python library dependencies and then install Kivy, like:
$: python3 -m venv ~/kivy_venv $: source ~/kivy_venv/bin/activate $: pip3 install --upgrade --user pip setuptools $: pip3 install wheel $: pip3 install -U --force-reinstall Cython==0.29.9 $: pip3 install kivy
This can take a while, so relax and enjoy!
Saturday, April 02, 2016
Enable ClearType using Python
When I remote desktop to Windows machines most of the time the fonts just looks ugly. This can be improved by enabling ClearType and I do this every time I connect to a box which I do several times a day. Below is a Python code that enables ClearType which I shamelessly copied from StackOverflow.
Reference(s):
http://stackoverflow.com/questions/5676768/enable-disable-cleartype-in-windows7
Reference(s):
http://stackoverflow.com/questions/5676768/enable-disable-cleartype-in-windows7
Thursday, March 31, 2016
Howto: Installing pywin32 on Python 3.5.1 64-bit
Installing Python for Windows Extensions on Python 3.5.1 64-bit
If you are getting the following error message in importing win32gui install VC++ 2010 redistributable.
Reference(s):
http://sourceforge.net/projects/pywin32/
https://www.python.org/downloads/
C:\>pip install pypiwin32
If you are getting the following error message in importing win32gui install VC++ 2010 redistributable.
>>> import win32gui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
Reference(s):
http://sourceforge.net/projects/pywin32/
https://www.python.org/downloads/
Saturday, January 09, 2016
py2exe does not work yet on Python 3.5
Installing py2exe on Python 3.5 (64-bit) using pip works (pip install py2exe) but it can't build standalone executable yet - run-py3.5-win-amd64.exe does not exists.
Saturday, December 12, 2015
Check Windows input message queue idle in Python
Code below shows how to check for message queue input idle. Note that WaitForInputIdle waits only once per process on any thread. So if one of the thread returns idle then it will return right away.
Tested on:
Windows 10 TH2 (build 1511)
Python 3.5.1 64-bit
Also need to install pywin32, like:
This should be run on elevated prompt.
Tested on:
Windows 10 TH2 (build 1511)
Python 3.5.1 64-bit
Also need to install pywin32, like:
c:\> pip install pypiwin32
Wednesday, May 06, 2015
pip fails to run on Windows 10 E build 10074
Installed Windows 10 E 64-bit build 10074, followed by Python 2.7.9 32-bit. Running pip fails the with message
https://github.com/pypa/pip/issues/2748
This issue is also reported in Python.org, see
https://bugs.python.org/issue24127
Workaround:
Fatal error in launcher: Job information querying failedIssue is open in Github, see below
https://github.com/pypa/pip/issues/2748
This issue is also reported in Python.org, see
https://bugs.python.org/issue24127
Workaround:
C:\>python -m pip install comtypes
Sunday, April 05, 2015
Get domain controller from NetBios name using Python
Where:
myad is the NetBios name of the domain.
Note: Using ActiveState Python 2.7.x.
myad is the NetBios name of the domain.
Note: Using ActiveState Python 2.7.x.
Sunday, November 02, 2014
Send email via GMAIL using Python
Send email via GMAIL using Python.
Note:
Need to disable CAPTCHA and enable access for less secure apps
https://www.google.com/settings/security
https://accounts.google.com/DisplayUnlockCaptcha
References:
www.mkyong.com/python/how-do-send-email-in-python-via-smtplib/
http://joequery.me/guides/python-smtp-authenticationerror/
Note:
Need to disable CAPTCHA and enable access for less secure apps
https://www.google.com/settings/security
https://accounts.google.com/DisplayUnlockCaptcha
References:
www.mkyong.com/python/how-do-send-email-in-python-via-smtplib/
http://joequery.me/guides/python-smtp-authenticationerror/
Send email in Python using an smtp server with MIMEText
This is similar to this post but using MIMEText to make it a little readable.
Sunday, October 19, 2014
Set IPython qtconsole font to terminus
ipython qtconsole --ConsoleWidget.font_size=10 --ConsoleWidget.font_family="Terminus"
Or create ~/.ipython/profile_default/ipython_config.py Reference(s):
http://stackoverflow.com/questions/9906938/change-ipython-qtconsole-settings
Sunday, November 28, 2010
Check the version of numpy
NumPy is the fundamental package needed for scientific computing with Python, see link for more information. To get the version of the installed numpy package, in a Python shell (e.g., IPython), do:
~ts
import numpy numpy.version.version
~ts
Monday, November 03, 2008
wxPython nuggets
Sample code playing around canvas, cursors, images.
Another wxPython Tutorial
The wxPython Tutorial - The wxPython tutorial is the largest and most advanced wxPython tutorial available on the Internet. Suitable for beginners and intermediate programmers
Rubberbanding in wxPython
Another wxPython Tutorial
The wxPython Tutorial - The wxPython tutorial is the largest and most advanced wxPython tutorial available on the Internet. Suitable for beginners and intermediate programmers
Rubberbanding in wxPython
Sunday, November 02, 2008
Sourceforge links of interest
Some useful links for SourceForge users.
Quickstart Guide to Subversion on SourceForge
Recommended Software Configuration - this includes how to configure SVN clients, cvs and many more.
~TS
Quickstart Guide to Subversion on SourceForge
Recommended Software Configuration - this includes how to configure SVN clients, cvs and many more.
~TS
Saturday, August 16, 2008
Print active application and title using pywinauto
Code snippet below shows how to get the window title and application name of the active application. That is the application on top of the z-order. Need to install pywinauto to get this to work.
~ts
import pywinauto.application import pywinauto.handleprops as _handleprops import pywinauto.win32functions as _win32functions import time while 1: hwnd = _win32functions.GetForegroundWindow() print "Active Window title is %s"%(_handleprops.text(hwnd)) print "Application name is %s"%(pywinauto.application.process_module(_handleprops.processid(hwnd))) time.sleep(2)
~ts
Monday, July 02, 2007
Generating UUID in Jython
I have been poking around STAX/STAF recently and I found a need to generate UUID or GUID in Windows. I tried uuid module in CPython but I can't call it inside my STAX job. I tried to create STAX process but I noticed that if the program is under heavy usage I cannot guarantee that the STAX process that runs the CPython gets the resulting UUID string. Since STAX is using Jython, I reasoned out that this should be possible in Java. A quick search in Google shows java.util.UUID. This class is just what I need.
So, basically, in Jython I can generate a UUID using the following command:
import java
print java.util.UUID.randomUUID()
~ts~
Subscribe to:
Posts (Atom)
Formatting code in Blogger
I have been using Github gists to share code and I have no plan of abandoning it. For smaller/one liners, I sometimes use div element with ...

-
Installing MonoDevelop in OpenSUSE 12.2 from its repository was very easy. When running it for the first time though I got the message: Th...
-
Tried to update my Ubuntu host today and it did pickup that new version of VirtualBox is available (4.1.8). All other packages installed pro...
-
This is quick start guide how to run ssh server on QNX. Tested on QNX 6.5 (650SP1-VM.tar). # ssh-keygen -t dsa -b 1024 -f /etc/ssh/ssh...