Skip to content

Decoding Pip Installation: A Comprehensive Troubleshooting Guide from ParseException to SSLError to C++ Compilation Errors

If you're reading this, chances are you just confidently typed pip install -r requirements.txt into your command line, only to be met with a screen full of glaring red error messages. Don't be discouraged, you're not alone. Setting up Python project environments, especially when dealing with complex dependencies (like open-source AI projects), often involves encountering various errors.

This article will guide you step-by-step through a real-world troubleshooting case, conquering three of the most common "roadblocks" in the pip installation process. Let's start with the first failure.

Level 1: Syntax Trap - ParseException: Expected string_end, found '['

Symptom:

When you run pip install, the terminal immediately throws the following error:

ERROR: Exception:
Traceback (most recent call last):
  ...
pip._vendor.pyparsing.exceptions.ParseException: Expected string_end, found '[' (at char 11), (line:1, col:12)

Diagnosis:

The core of this error is ParseException, which means "parsing exception." It tells us that pip encountered syntax it couldn't understand while reading your requirements.txt file. The error message Expected string_end, found '[' means that pip expected a line to end but unexpectedly found an opening square bracket [.

Let's check the requirements.txt file:

The problem lies in the last line. When specifying "extras" dependencies for a package in the requirements.txt file, you shouldn't use quotes around the package name and square brackets. pip cannot correctly parse this quoted notation.

Solution:

Edit your requirements.txt file, removing the unnecessary quotes.

Before:

nemo_toolkit["asr"]

After:

nemo_toolkit[asr]

Save the file and try again. Great, the first problem is solved!


Level 2: Network Firewall - SSLError and Connection Timeout

Symptom:

After fixing the syntax issue, you run the installation command again, but the terminal starts displaying a lot of WARNING and ERROR messages, eventually ending in failure:

WARNING: Retrying (...) after connection broken by 'SSLError(SSLError(8, 'EOF occurred in violation of protocol ...'))'
...
Could not fetch URL https://pypi.org/simple/numpy/: There was a problem confirming the ssl certificate...
...
ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
ERROR: No matching distribution found for numpy

Diagnosis:

This time, the enemy is the network. SSLError and connection broken indicate that your computer is having trouble establishing a secure connection (HTTPS) with pip's official package server, pypi.org. This usually has two main causes:

  1. Network Restrictions: Especially in mainland China, accessing foreign servers (like pypi.org) can be unstable or subject to interference, leading to connection interruptions.
  2. Proxy Issues: If you're using proxy software, it might be replacing the website's SSL certificate, and if this certificate isn't trusted by your system, pip will refuse the connection for security reasons.

Because the connection fails, pip cannot obtain the package version list at all, so it reports from versions: none, ultimately leading to no matching distribution being found.

Solution:

Take a two-pronged approach to solve the network problem.

  1. (If using a proxy) Turn off the proxy: The most direct method is to temporarily disable your proxy software to rule out its interference with the SSL certificate.
  2. Switch to a domestic mirror source: This is the ultimate solution for access speed and stability. Add the -i parameter after the pip command to specify a domestic mirror server.

Now, let's execute the command with a "combo punch":

bash
# The -i parameter specifies the use of Tsinghua University's mirror source
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

Some commonly used domestic mirror sources:

  • Tsinghua University: https://pypi.tuna.tsinghua.edu.cn/simple
  • Aliyun: https://mirrors.aliyun.com/pypi/simple/
  • China University of Science and Technology: https://pypi.mirrors.ustc.edu.cn/simple/

After execution, you'll find that the download speed is very fast, and SSLError has also disappeared. It looks like success is just around the corner, but...


Level 3: Compilation Maze - Microsoft Visual C++ 14.0 is required

Symptom:

The installation process proceeds smoothly for a while, but when installing a specific package (e.g., texterrors in this example), a new error pops up:

  Running setup.py install for texterrors ... error
  ...
  building 'texterrors_align' extension
  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  ...
error: legacy-install-failure

Diagnosis:

This error is very clear: Your system is missing a C++ compilation environment.

The core parts of many high-performance Python libraries (especially scientific computing libraries) are written in C or C++ to achieve maximum running speed. When installing these libraries, pip will first try to download a version that has already been compiled for you (called a Wheel file, .whl). But if it cannot find a pre-compiled version suitable for your system (e.g., Windows + Python 3.10), pip will download the source code and try to compile it on your computer on the spot.

To compile C++ code on Windows, you must install Microsoft's official C++ Build Tools. Because you don't have them on your system, the compilation fails.

Solution:

Follow the error message and install the required compilation tools.

  1. Visit and Download: Open the link in the error message Microsoft C++ Build Tools and download the installer.
  2. Select Installation Components: Run the downloaded vs_buildtools.exe. In the "Workloads" tab, be sure to check "Desktop development with C++".
  3. Install: Click Install and wait patiently. This will download several GB of files.
  4. Restart: After installation, it's best to restart your computer, or at least close all command-line windows and reopen them to ensure the environment takes effect.

Launch the Final Offensive:

Now your system is all set. Reopen a command-line window, activate your virtual environment, and execute our final, perfect installation command:

bash
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

This time, when pip needs to compile texterrors again, it will successfully find the C++ compiler and complete the task smoothly. After a while, you will see the long-awaited Successfully installed ....


This journey tells us that although pip's error messages may seem complex, they are often honest guides. Learn to read them carefully, understand their meaning, and you can transform from a passive error recipient into an active problem solver.

Hopefully, this guide will clear some obstacles for your future Python journey. Happy coding!