Backend Development 3 min read

Building a Python WeChat Message Sender with itchat and PyInstaller

This tutorial explains how to set up a Python environment, install the itchat and pyinstaller libraries, write a script that logs into WeChat and sends repeated messages to a specified contact, and then package the script into a standalone executable file.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Building a Python WeChat Message Sender with itchat and PyInstaller

This guide provides step‑by‑step instructions for creating a WeChat message‑spamming tool using Python.

1. Environment preparation

Install Python 3.6, then add the required third‑party libraries:

<code>pip install itchat</code>
<code>pip install pyinstaller</code>

2. Core code

<code>import itchat</code><code>import time</code><code>print("请扫描弹出的扫二维码")</code><code>itchat.auto_login(hotReload=True)</code><code>boom_name = input("请输入想发送的人:")</code><code>message = input("请输入发送的内容:")</code><code>number = int(input("请输入发送的次数:"))</code><code>boom_obj = itchat.search_friends(remarkName=boom_name)[0]['UserName']</code><code>for i in range(1, number+1):</code><code>    time.sleep(0.01)</code><code>    print("正在发送第%d遍" % i)</code><code>    itchat.send_msg(msg=message, toUserName=boom_obj)</code>

3. Packaging the project into an executable

Use PyInstaller to create a single‑file executable:

<code>pyinstaller -F wechat.py</code>

After the build finishes, the executable appears in the dist directory. Running it will launch the script, prompting for the target contact, message content, and repeat count, then automatically send the messages via WeChat.

Images in the original article illustrate the command line output and the successful execution of the packaged program.

PythonautomationWeChatExecutablepyinstalleritchat
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.