[Python] Unable to run pip on venv (Group Policy error)

Discussão em 'Python' iniciado por Stack, Junho 16, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to run a small Python script using a venv on VS Code. The script uses two external packages listed in the requirements.txt file included on the scripts package.

    When I try to run the script, I get the following error because one of the external packages is missing:

    File "C:\Users\somepath\scriptfolder\thescript.py", line 17, in <module>
    import aiofiles
    ModuleNotFoundError: No module named 'aiofiles'


    So I try to install the missing external package manually using the PIP command, but then I get the following error

    (.venv) PS C:\Users\somepath\scriptfolder> pip install aiofiles==22.1.0
    Program 'pip.exe' failed to run: This program is blocked by group policy. For more information, contact your system administratorAt line:1 char:1
    + pip install aiofiles==22.1.0
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
    At line:1 char:1
    + pip install aiofiles==22.1.0
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ResourceUnavailable: :)) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed

    (.venv) PS C:\Users\somepath\scriptfolder>


    Relevant notes:


    • Python interpreter works fine on both venv and local drive (e.g. run from cmd).


    • PIP is installed correctly on Windows (runs fine when I run it from cmd)


    • If I look in the scriptfolder\venv\Scripts folder I can see the following:

      activate.bat deactivate.bat python.exe pip.exe pip3.11.exe pythonw.exe

    Continue reading...

Compartilhe esta Página