Many small businesses have a few scripts that have run quietly for years: exporting reports, renaming files, reading data from time clocks or sending automatic emails. The author may have left, and no one remembers which Python version the script uses. Python 2 officially reaches end of support on January 1, 2020, so now is the time to check this code.
What end of support for Python 2 means
According to the Python development team, from January 1, 2020 there will be no more bug reports, patches or new changes for Python 2. This includes security vulnerabilities: if someone finds a security flaw, the team will no longer fix it. The team also said the final 2.7 release will only merge fixes that already existed up to the end of January 1, 2020, and nothing more.
This does not mean scripts stop running on that day. But they will not be patched when new bugs appear, and third-party libraries gradually drop support. The risk grows over time, especially if the script handles customer data or has network connections.
Inventory scripts and internal tools
Before migrating, know what you have. Suggested steps:
- Find the scripts: check automatic schedules (cron, Task Scheduler), shared folders and old servers.
- Record the purpose: what each script does, who uses it, when it runs, and its inputs and outputs.
- Identify the Python version: look at the first line of the file or the calling command (python or python2), and the installed libraries.
- Assess importance: scripts serving accounting, sales or reporting come first.
- Assign an owner for each script. If nobody uses it anymore, it can be retired and archived.
A simple spreadsheet with these columns is enough to start.
Migrating to Python 3 step by step
There's no need to migrate everything at once. A practical approach:
- Back up the source code and sample data before making changes.
- Run the original to know the correct result, then use it as a baseline for comparison.
- Use helper tools such as 2to3, which ships with Python, to suggest what to change, then review by eye because the tool cannot catch every case.
- Watch for common differences: the print statement, integer division, string handling and character encoding (especially accented Vietnamese), and library module names.
- Update third-party libraries to versions that support Python 3, or find replacements.
- Comparison testing: run the new version on the same data and compare the results with the old one.
- Run both in parallel for a while before switching off the old one.
If a script is very short, sometimes rewriting it from scratch in Python 3 is faster than fixing it line by line.
Security risks if left unchanged
If you can't migrate right away, reduce the risk:
- Don't let Python 2 scripts be accessed directly from the Internet.
- Run scripts under an account with limited privileges, not admin rights.
- Isolate the machine running the scripts in the internal network and keep the operating system updated.
- Set a clear deadline for the migration instead of leaving it open-ended.
Similar to upgrading PHP for WordPress when an old version loses support, you can review the article PHP 5.6 and 7.0 reach end of support. The habit of recognizing scam emails also matters, since many incidents start with email; see phishing emails: 7 warning signs. For old software causing browser warnings, there is an example in Chrome 68 marks HTTP as not secure, and on user data you can read lessons from Cambridge Analytica.
Ví dụ ba loại script thường gặp
Script xuất báo cáo cuối ngày từ phần mềm bán hàng: thường đơn giản, chuyển nhanh, ưu tiên kiểm tra mã hoá tiếng Việt khi ghi tệp.
Script đồng bộ dữ liệu chấm công sang bảng lương: nhạy cảm vì liên quan đến tiền, cần chạy song song bản cũ và bản mới ít nhất một kỳ lương để đối chiếu.
Script gửi email tự động nhắc khách: kiểm tra cả thư viện gửi mail và cấu hình xác thực, vì thư viện cũ có thể không còn hỗ trợ cách đăng nhập hiện nay.
Tài liệu chính thức nên đọc ở đâu
Trang “How to port Python 2 Code to Python 3” trên docs.python.org nêu rõ Python 2 đã hết vòng đời từ đầu năm 2020 và không còn báo lỗi, bản sửa hay thay đổi nào. Trang cũng cho biết hướng dẫn chuyển đổi gốc đã ngừng duy trì từ Python 3.11 và dẫn tới các hướng dẫn của bên thứ ba; thông tin tra ngày 03/12/2026. Vì vậy hãy xem hướng dẫn nào còn được cập nhật, thay vì dựa vào bài cũ.
Checklist từng script trước khi ngưng bản cũ
- Có bản sao lưu mã nguồn và dữ liệu mẫu.
- Có kết quả đầu ra của bản cũ để so sánh.
- Bản mới chạy bằng tài khoản quyền hạn chế.
- Có nhật ký (log) ghi lỗi và ai nhận thông báo khi script thất bại.
- Có người chịu trách nhiệm và ghi tên vào bảng kiểm kê.
Khi nào nên thay script bằng công cụ khác
Nếu một script chỉ làm việc mà bảng tính, phần mềm kế toán hoặc công cụ tự động hoá hiện có đã làm được, việc giữ lại script đó chỉ là thêm nợ kỹ thuật. Hãy hỏi người dùng thực sự cần kết quả gì, rồi chọn cách đơn giản nhất. Script nào còn lại thì đặt tên rõ, ghi chú đầu tệp (mục đích, người phụ trách, ngày kiểm tra gần nhất).
If you need help reviewing servers or internal scripts, you can contact HVSC's Technology team via the page server and website security.
2026 update: Python 2.7.18 was released in April 2020 as the final version, and Python 2 is no longer supported. New Python 3 releases continue to be published; check python.org to see which versions are currently supported.
FAQ
Do Python 2 scripts stop working on January 1, 2020?
No. But there will be no more patches, including security fixes, so the risk gradually increases.
Are there tools to help migrate to Python 3?
Yes, such as 2to3, which ships with Python. The tool only makes suggestions; you still need to review and test.
What if we can't migrate in time?
Limit access rights, don't expose scripts to the Internet, and set a clear migration deadline.
Reference sources
- Python.org — Sunsetting Python 2: https://www.python.org/doc/sunset-python-2/
- Python Docs — How to port Python 2 Code to Python 3: https://docs.python.org/3/howto/pyporting.html
Need advice on websites, software or security?
Describe the problem, and HVSC engineers will discuss the scope and options suited to your business.
FAQ
Do Python 2 scripts stop working on January 1, 2020?
No. But there will be no more patches, including security fixes, so the risk gradually increases.
Are there tools to help migrate to Python 3?
Yes, such as 2to3, which ships with Python. The tool only makes suggestions; you still need to review and test.
What if we can't migrate in time?
Limit access rights, don't expose scripts to the Internet, and set a clear migration deadline.
- SSH Basics: Logging In to a Server with a Key Instead of a Password
- Web Vitals: Reading the Report and Fixing the Right Spots
- Scammed by Bank Transfer: What to Do in the First 60 Minutes













▶
▶
▶
▶
▶