I recently started a toy project to build a ‘Stock Price Tracker’ using Python within Visual Studio 2022. Working in the IT department of a securities firm, I’m used to handling data, but setting up a local Python environment from scratch brought unexpected challenges.
We often say, “Environment setup is half the battle.” For those developing behind strict corporate firewalls or on non-English Windows systems, this is especially true.
Here is a definitive guide to resolving the two biggest headaches I encountered: SSL Certificate errors (pip) and Encoding mismatches (CP949 vs. UTF-8).
1. The Firewall Wall: SSL Certificate Errors
When I tried to install the finance-datareader library, my terminal threw a massive red error:
SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed...'))
The Cause: Corporate networks often use Self-signed Certificates (SSL Inspection) to monitor traffic. Python’s pip strictly trusts only public authorities, so it flags the company’s certificate as a security threat and blocks the connection.
The Solution: Configure pip.ini (The Permanent Fix)
Typing --trusted-host for every command is tedious. The best practice is to set up a global configuration file.
- Type
%APPDATA%in your file explorer address bar (usuallyC:\Users\Username\AppData\Roaming). - Create a new folder named
pip. - Inside, create a text file named
pip.iniand paste the following:
[Content of pip.ini]
Ini, TOML
[global]
trusted-host = pypi.org files.pythonhosted.org
Once saved, pip will trust these hosts automatically, bypassing the SSL error for all future installations.
2. The Character Trap: Encoding Issues (CP949 vs. UTF-8)
After fixing the installation, I ran my code, only to be stopped by a runtime error:
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xc1...
The Cause: On Korean (or other non-English) Windows systems, Visual Studio defaults to saving files in CP949 (EUC-KR). However, Python 3 treats source code as UTF-8 by default. As soon as I added a comment in Korean, the interpretor choked on the mismatch.
Manually selecting “Save with Encoding” for every file is inefficient. The standard solution is to enforce rules using .editorconfig.
The Solution: Enforce Standards with .editorconfig
Create a file named .editorconfig in the root directory of your project (or solution) and add the following:
[Content of .editorconfig]
Ini, TOML
# Top-most EditorConfig file
root = true
# Settings for all files
[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
charset = utf-8: The game changer. It forces VS to save all files in UTF-8 automatically.end_of_line = lf: Prevents the infamous CRLF (Windows) vs. LF (Linux/Mac) git diff issues.
This file is a “must-have” for modern development, ensuring consistency regardless of the IDE or OS your team uses.
3. Conclusion
With just two configuration files, the environment is finally stable.
pip.inisolved the network security blockers..editorconfigsolved the cross-platform encoding issues.
These “config files” are the unsung heroes of development. Now that the red error messages are gone, I can finally focus on the fun part: visualizing stock data.
Key Takeaways:
- Environment: Visual Studio 2022, Python 3.11
- Essential Files:
%APPDATA%\pip\pip.ini,ProjectRoot\.editorconfig
#Python #VisualStudio2022 #DevOps #CodingTips #SSLError #Encoding #UTF8