Pycharm error 'pkg-config' is required to install this package on Windows

  • 9 months ago
Comment

ChatGPTChatGPT
1 / 1

The error message "pkg-config is required to install this package" in PyCharm on Windows typically occurs when you are trying to install a Python package that requires the pkg-config utility, but pkg-config is not installed or not accessible on your system.

pkg-config is a command-line utility used to retrieve information about installed libraries, such as their version, compiler flags, and linker flags. Some Python packages rely on pkg-config to find the necessary dependencies and build correctly.

To resolve this issue, you need to install pkg-config on your Windows system and make sure it is accessible from the PyCharm environment. Follow these steps:

  1. Install pkg-config:
    pkg-config is not a native utility on Windows, but you can install it using the MSYS2 environment, which provides a collection of software and tools for building and running software on Windows.

    • Download and install MSYS2 from the official website: https://www.msys2.org/
    • During the installation, choose a path without spaces (e.g., C:\msys64).
    • After the installation, open the MSYS2 MinGW 64-bit shell from the Start menu.
  2. Update MSYS2 Packages:
    In the MSYS2 MinGW 64-bit shell, run the following commands to update the package database and core packages:

    pacman -Syu

    Follow the prompts to update the packages. This step is essential to ensure you have the latest packages and repositories.

  3. Install pkg-config:
    In the same MSYS2 MinGW 64-bit shell, install pkg-config by running the following command:

    arduino
    pacman -S mingw-w64-x86_64-pkg-config

    This will install pkg-config on your system.

  4. Add MSYS2 bin Directory to Path:
    To make pkg-config accessible from PyCharm, add the MSYS2 bin directory to your system's PATH environment variable.

    • Right-click on "This PC" or "My Computer" and select "Properties."
    • Click on "Advanced system settings" on the left sidebar.
    • Click the "Environment Variables" button at the bottom.
    • In the "System variables" section, scroll down and select the "Path" variable.
    • Click the "Edit" button.
    • Add the path to the MSYS2 bin directory (e.g., C:\msys64\mingw64\bin) at the end of the "Variable value" field.
    • Click "OK" to save the changes.
  5. Restart PyCharm:
    After making these changes, close and reopen PyCharm to ensure it picks up the updated environment variables.

Now, you should be able to install Python packages that require pkg-config from within PyCharm on your Windows system without encountering the error message.