When I use the pip command to install a python module ( pip install requests
) or upgrade pip ( python -m pip install --upgrade pip
) in windows, I meet the 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\\__init__.py' Consider using the `--user` option or check the permissions.
After investigating for some time, I finally find the solution to fix the above error and successfully install the python module. The reason for this error is because you do not run the pip install command with the admin role, there are two methods to run the python install command with admin permission as following.
1. Run Windows Powershell As Admin.
- Right-click the start button at windows 10 bottom left corner.
- Then click Windows PowerShell(Admin) menu item in the popup menu list.
- Click Yes in the popup dialog to allow it to run. And then you can run the pip install command in this PowerShell window to install the python module or upgrade the pip, and the installation will be successful.
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 https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl 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
3. Question & Answer.
3.1 How to fix could not install packages due to an EnvironmentError: [WinError 123].
- My python version is 3.9, and I want to download and install some python packages such as
scipy
in the python environment. But when I install the python packages, it prompts an error message which said could not install the package because of an environment error, the error number is WinError 123. It says the syntax of the volume label, directory, or file name is incorrect. Then I try to reinstall the visual studio on my PC to fix the error, but the error still exists. Because I use the PyCharm to develop my python program, so I also add the--user
parameter to run the Pycharm application with administrator permission, but it still can not fix the error. Can anyone tell me how to fix it? Thanks. - As the error message says there is a syntax error in the volume label, directory, or file name, so you had better check the directory path syntax carefully. The best practice for file paths is that you should not add whitespace in the directory or file path. If your directory or file path contains whitespace, you had better remove it. If the pip or python install directory contains whitespace, you had better reinstall the python or pip to a folder that does not contain whitespace in the folder path( for example c:\python3.9).
- This error may occur when your python version is outdated or very fresh new. Because the python package that you want to install may do not have the related wheels for the outdated or more recent python version. So to fix this error, you can force install the package older version on your new python version from the package official website with the official old version wheel (
pip install --only-binary :all: <failing_package>
). Or you can download the unofficial wheel version from the Unofficial Windows Binaries for Python Extension Packages and install it with the command (pip install <path\to\failing_package.whl>
). - Some times you may need to bypass the python library cached version in your local os with the
--no-cache-dir
argument when you run the pip install command (pip install --no-cache-dir <package-name>
), because the locally cached library version may conflict with the new version of python.
this one worked on me. thank you
Because I need to run under an environment, so I used pip install *library*–upgrade pip –user
It works! Thank you!!
thanks a lot it helped me
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.
“pip install opencv-contrib-python –user”
it worked for me
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 setup.py 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…
even i am getting the same error …. Winerror 87
can anyone tell the solution
Open your anaconda cmd in Run as administrator mode then apply above code….it is working for me