[Python] python3 virtual environment on MSYS2

Discussão em 'Python' iniciado por Stack, Maio 20, 2025.

  1. Stack

    Stack Membro Participativo

    I have installed MSYS2 on windows. And installed few packages (pandas matplotlib) via pacman.

    I also want install some non-MSYS2 packages. Then I got a Error message.

    warning: externally-managed-environment

    × This environment is externally managed
    ╰─> To install Python packages system-wide, try 'pacman -S
    $MINGW_PACKAGE_PREFIX-python-xyz', where xyz is the package you
    are trying to install.

    If you wish to install a non-MSYS2-packaged Python package,
    create a virtual environment using 'python -m venv path/to/venv'.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.

    If you wish to install a non-MSYS2 packaged Python application,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. Make sure you have $MINGW_PACKAGE_PREFIX-python-pipx
    installed via pacman.

    note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
    hint: See PEP 668 for the detailed specification.


    Well. I just use python -m venv venv to create a virtual python environment. And activate it.

    [le@ZXL][~]$: cd pyevenv/
    [le@ZXL][~/pyevenv]$: ls
    venv
    [le@ZXL][~/pyevenv]$: source venv/bin/activate
    ((venv) ) [le@ZXL][~/pyevenv]$: pip install pandas


    But it will return a fatal error

    C:/msys64/tmp/pip-install-yfasx6im/ninja_9259a8f70f0e41668e16c17a4d97d8e5/ninja-upstream/src/subprocess-posix.cc:18:10: fatal error: sys/select.h: No such file or directory
    18 | #include <sys/select.h>
    | ^~~~~~~~~~~~~~
    compilation terminated.
    make[2]: *** [_deps/ninja-build/CMakeFiles/libninja.dir/build.make:429: _deps/ninja-build/CMakeFiles/libninja.dir/src/subprocess-posix.cc.o] Error 1
    make[1]: *** [CMakeFiles/Makefile2:193: _deps/ninja-build/CMakeFiles/libninja.dir/all] Error 2
    make: *** [Makefile:136: all] Error 2

    *** CMake build failed
    [end of output]



    It seems that python-pip on MSYS2 does not identify the current system. But I do not know how to solve it.

    Is there a way to install non-MSYS2 python packages on Windows? What did i do wrong

    Continue reading...

Compartilhe esta Página