<?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 Ricky</title><link>https://linzeyan.github.io/categories/python/</link><description>Recent content in Python on Ricky</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Sun, 04 Jan 2026 07:06:28 +0800</lastBuildDate><atom:link href="https://linzeyan.github.io/categories/python/index.xml" rel="self" type="application/rss+xml"/><item><title>Python Numbers Every Programmer Should Know</title><link>https://linzeyan.github.io/posts/2026/20260104-python-numbers-every-programmer-should-know/</link><pubDate>Sun, 04 Jan 2026 07:06:28 +0800</pubDate><guid>https://linzeyan.github.io/posts/2026/20260104-python-numbers-every-programmer-should-know/</guid><description>&lt;ul>
&lt;li>&lt;a href="https://mkennedy.codes/posts/python-numbers-every-programmer-should-know/" target="_blank" rel="noopener">Python Numbers Every Programmer Should Know&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Python's many command-line utilities</title><link>https://linzeyan.github.io/posts/2024/20240706-cli-tools/</link><pubDate>Sat, 06 Jul 2024 20:39:01 +0800</pubDate><guid>https://linzeyan.github.io/posts/2024/20240706-cli-tools/</guid><description>&lt;ul>
&lt;li>&lt;a href="https://www.pythonmorsels.com/cli-tools/" target="_blank" rel="noopener">Python&amp;rsquo;s many command-line utilities&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>These are Python&amp;rsquo;s most helpful general-purpose command-line tools.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Command&lt;/th>
&lt;th>Purpose&lt;/th>
&lt;th>More&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>python -m http.server&lt;/code>&lt;/td>
&lt;td>Start a simple web server&lt;/td>
&lt;td>&lt;a href="https://www.pythonmorsels.com/http-server/" target="_blank" rel="noopener">Video&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>python -m webbrowser&lt;/code>&lt;/td>
&lt;td>Launch your web browser&lt;/td>
&lt;td>&lt;a href="https://docs.python.org/3/library/webbrowser.html#command-line-interface" target="_blank" rel="noopener">Docs&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>python -m json.tool&lt;/code>&lt;/td>
&lt;td>Nicely format JSON data&lt;/td>
&lt;td>&lt;a href="https://docs.python.org/3/library/json.html#module-json.tool" target="_blank" rel="noopener">Docs&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>python -m calendar&lt;/code>&lt;/td>
&lt;td>Show a command-line calendar&lt;/td>
&lt;td>&lt;a href="https://docs.python.org/3/library/calendar.html#command-line-usage" target="_blank" rel="noopener">Docs&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="httpserver">&lt;code>http.server&lt;/code>&lt;/h3>
&lt;p>Running the &lt;code>http.server&lt;/code> module as a script will start a web server on port 8000 that hosts files from the current directory. I use this &lt;em>all the time&lt;/em> to preview Sphinx documentation sites (especially when using Sphinx&amp;rsquo;s &lt;code>dirhtml&lt;/code> option which is &lt;em>all about&lt;/em> subdirectories of &lt;code>index.html&lt;/code> files).&lt;/p></description></item><item><title>A python script that allows your terminal to snow.</title><link>https://linzeyan.github.io/posts/2023/20231224-snow/</link><pubDate>Sun, 24 Dec 2023 15:40:00 +0800</pubDate><guid>https://linzeyan.github.io/posts/2023/20231224-snow/</guid><description>&lt;ul>
&lt;li>&lt;a href="https://github.com/sontek/snowmachine" target="_blank" rel="noopener">A python script that allows your terminal to snow.&lt;/a>&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>docker run --rm -ti sontek/snowmachine tree --color rainbow --particle &lt;span style="color:#e6db74">&amp;#34;*&amp;#34;&lt;/span> --snow true --lights-color rainbow
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item><item><title>Using Python for multimedia: video, audio, and images</title><link>https://linzeyan.github.io/posts/2020/20200531-105371827/</link><pubDate>Sun, 31 May 2020 17:48:10 +0800</pubDate><guid>https://linzeyan.github.io/posts/2020/20200531-105371827/</guid><description>&lt;ul>
&lt;li>&lt;a href="https://blog.csdn.net/ZackSock/article/details/105371827" target="_blank" rel="noopener">Using Python for multimedia: video, audio, and images&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Python install module issues</title><link>https://linzeyan.github.io/posts/2020/20200304-i-cant-install-python-ldap/</link><pubDate>Wed, 04 Mar 2020 15:43:38 +0800</pubDate><guid>https://linzeyan.github.io/posts/2020/20200304-i-cant-install-python-ldap/</guid><description>&lt;ul>
&lt;li>&lt;a href="https://stackoverflow.com/questions/4768446/i-cant-install-python-ldap" target="_blank" rel="noopener">I can&amp;rsquo;t install python-ldap&lt;/a>&lt;/li>
&lt;/ul>
&lt;h4 id="python-ldap">python-ldap&lt;/h4>
&lt;blockquote>
&lt;p>&lt;a href="https://www.python-ldap.org/en/latest/installing.html" target="_blank" rel="noopener">https://www.python-ldap.org/en/latest/installing.html&lt;/a>&lt;/p>&lt;/blockquote>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ pip install python-ldap
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>In file included from Modules/LDAPObject.c:9:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Modules/errors.h:8: fatal error: lber.h: No such file or directory
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>
&lt;p>Debian/Ubuntu:
&lt;code>sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>RedHat/CentOS:&lt;/p>
&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>sudo yum install python-devel openldap-devel
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo yum groupinstall &lt;span style="color:#e6db74">&amp;#34;Development tools&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="molecule">molecule&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ pip install molecule
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>error: command &lt;span style="color:#e6db74">&amp;#39;gcc&amp;#39;&lt;/span> failed with exit status &lt;span style="color:#ae81ff">1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ----------------------------------------
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Command &lt;span style="color:#e6db74">&amp;#34;/usr/bin/python2 -u -c &amp;#34;&lt;/span>import setuptools, tokenize;__file__&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#39;/tmp/pip-install-I5DGC3/psutil/setup.py&amp;#39;&lt;/span>;f&lt;span style="color:#f92672">=&lt;/span>getattr&lt;span style="color:#f92672">(&lt;/span>tokenize, &lt;span style="color:#e6db74">&amp;#39;open&amp;#39;&lt;/span>, open&lt;span style="color:#f92672">)(&lt;/span>__file__&lt;span style="color:#f92672">)&lt;/span>;code&lt;span style="color:#f92672">=&lt;/span>f.read&lt;span style="color:#f92672">()&lt;/span>.replace&lt;span style="color:#f92672">(&lt;/span>&lt;span style="color:#e6db74">&amp;#39;\r\n&amp;#39;&lt;/span>, &lt;span style="color:#e6db74">&amp;#39;\n&amp;#39;&lt;/span>&lt;span style="color:#f92672">)&lt;/span>;f.close&lt;span style="color:#f92672">()&lt;/span>;exec&lt;span style="color:#f92672">(&lt;/span>compile&lt;span style="color:#f92672">(&lt;/span>code, __file__, &lt;span style="color:#e6db74">&amp;#39;exec&amp;#39;&lt;/span>&lt;span style="color:#f92672">))&lt;/span>&lt;span style="color:#e6db74">&amp;#34; install --record /tmp/pip-record-Fy7V4X/install-record.txt --single-version-externally-managed --compile&amp;#34;&lt;/span> failed with error code &lt;span style="color:#ae81ff">1&lt;/span> in /tmp/pip-install-I5DGC3/psutil/
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>RedHat/CentOS:&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>yum -y install gcc gcc-c++ kernel-devel
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>yum -y install python-devel libxslt-devel libffi-devel openssl-devel
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="ansible">ansible&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ pip install ansible
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ImportError: No module named pkg_resources
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>yum install -y python-setuptools
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h4 id="import-pandas">&lt;code>import pandas&lt;/code>&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>ModuleNotFoundError: No module named &lt;span style="color:#e6db74">&amp;#39;_bz2&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>apt-get install -y libbz2-dev
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>yum install -y bzip2-devel
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="from-cv2-import-">&lt;code>from .cv2 import *&lt;/code>&lt;/h4>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>ImportError: libSM.so.6: cannot open shared object file: No such file or directory
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ImportError: libXrender.so.1: cannot open shared object file: No such file or directory
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ImportError: libXext.so.6: cannot open shared object file: No such file or directory
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>Ubuntu:&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>apt-get install libsm6
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>apt-get install libxrender1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>apt-get install libxext-dev
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>CentOS:&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>yum install libSM
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>yum install libXrender-devel
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>yum install libXext
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item><item><title>What the f*ck Python! 🐍</title><link>https://linzeyan.github.io/posts/2019/20191011-wtfpython-cn/</link><pubDate>Fri, 11 Oct 2019 14:32:20 +0800</pubDate><guid>https://linzeyan.github.io/posts/2019/20191011-wtfpython-cn/</guid><description>&lt;ul>
&lt;li>&lt;a href="https://github.com/leisurelicht/wtfpython-cn" target="_blank" rel="noopener">What the f*ck Python! 🐍&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Python Telegram Bot</title><link>https://linzeyan.github.io/posts/2019/20190711-python-telegram-bot/</link><pubDate>Thu, 11 Jul 2019 14:03:25 +0800</pubDate><guid>https://linzeyan.github.io/posts/2019/20190711-python-telegram-bot/</guid><description>&lt;ul>
&lt;li>&lt;a href="https://zaoldyeck.medium.com/%E6%89%8B%E6%8A%8A%E6%89%8B%E6%95%99%E4%BD%A0%E6%80%8E%E9%BA%BC%E6%89%93%E9%80%A0-telegram-bot-a7b539c3402a" target="_blank" rel="noopener">Part 1: Build a Telegram Bot Step by Step&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://zaoldyeck.medium.com/%E5%88%A9%E7%94%A8-olami-open-api-%E7%82%BA-chatbot-%E5%A2%9E%E5%8A%A0-nlp-%E5%8A%9F%E8%83%BD-e6b37940913d" target="_blank" rel="noopener">Part 2: Add NLP to the Chatbot&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://zaoldyeck.medium.com/add-custom-skill-into-chatbot-cef9bfeeef52" target="_blank" rel="noopener">Part 3: Add New Skills to the Chatbot&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://hackmd.io/@truckski/HkgaMUc24" target="_blank" rel="noopener">Python Telegram Bot Tutorial&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://kaive.me/2018/07/15/Python-telegram-bot/" target="_blank" rel="noopener">Write a Simple Telegram Bot with Python&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://github.com/python-telegram-bot/python-telegram-bot/wiki/Code-snippets" target="_blank" rel="noopener">Code snippets&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Sentry Source Code Development Notes</title><link>https://linzeyan.github.io/posts/2019/20190703-python-sentry-develop-notes-and-uwsgi-log-format/</link><pubDate>Wed, 03 Jul 2019 11:53:15 +0800</pubDate><guid>https://linzeyan.github.io/posts/2019/20190703-python-sentry-develop-notes-and-uwsgi-log-format/</guid><description>&lt;ul>
&lt;li>&lt;a href="https://chroming.gitlab.io/2018/09/26/edit_sentry_source_code/" target="_blank" rel="noopener">Sentry Source Code Development Notes&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://uwsgi-docs.readthedocs.io/en/latest/LogFormat.html" target="_blank" rel="noopener">Formatting uWSGI requests logs&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.postgresql.org/docs/9.3/libpq-pgpass.html" target="_blank" rel="noopener">PostgreSQL: Documentation: 9.3: The Password File&lt;/a>&lt;/li>
&lt;/ul></description></item></channel></rss>