How To Fix Could Not Install Packages Due To An Environmenterror: [winerror 5] Access Is Denied Error When Install Python Module In Windows

When i use pip command to install a python module ( pip install requests )  or upgrade pip ( python -m pip install --upgrade pip ) in windows, i meet below error message.

Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'C:\\Program Files (x86)\\Python37-32\\Lib\\site-packages\\pip\\'
Consider using the `--user` option or check the permissions.

After investigate some time, i finally find the solution to fix above error and successfully install the python module. The reason for this error is because you do not run the pip install command with admin role, there are two methods to run the python install command with admin permission as following.

1. Run Windows Powershell As Admin.

  1. Right click the start button at windows 10 bottom left corner.
  2. Then click Windows PowerShell(Admin) menu item in the popup menu list.
    right click windows start button click windows powershell admin menu item
  3. Click Yes in the popup dialog to allow it to run. And then you can run pip install command in this powershell window to install python module or upgrade pip, and the installation will be successfull.

2. Run Pip Install Command With –user Argument.

You can also fix this error by add –user argument to the pip command that you need to execute like below. This is very straight forward.

python -m pip install --upgrade pip --user
Collecting pip
  Using cached
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-19.1.1
READ :   How To Drop / Change Tables From SQLite3 Database In Django


  1. Hello, I tried both methods and carry on receiving the same error… “ERROR: Error [WinError 87] El parámetro no es correcto while executing command python egg_info
    ERROR: Could not install packages due to an EnvironmentError: [WinError 87] El parámetro no es correcto”

    Can you give another method, please? maybe in the path of the environment…


    1. even i am getting the same error …. Winerror 87
      can anyone tell the solution


  2. “pip install opencv-contrib-python –user”

    it worked for me


  3. So, I can’t run it again since pip successfully upgraded. Was it trying to delete the temp files it created? I still see pip.exe and other files in AppData\Local\Temp\pip-uninstall-_sc_2j8y\

    I can go ahead and delete those but I want to make sure it wasn’t trying to clean up other stuff that is now wasting space or could cause some weird issue later.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.