python - My terminal throws an OSError every time I try to update pip - Stack Overflow

admin2025-04-16  5

I run the command:

python.exe -m pip install --upgrade pip

But when I do I get an OSError saying my access is denied.

ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Python312\\Lib\\site-packages\\pip\\__init__.py'
Consider using the `--user` option or check the permissions.

How can I update it safely? I have tried downloading the package online but it doesn't work and found other answers saying use sudo but it's not safe.

I run the command:

python.exe -m pip install --upgrade pip

But when I do I get an OSError saying my access is denied.

ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Python312\\Lib\\site-packages\\pip\\__init__.py'
Consider using the `--user` option or check the permissions.

How can I update it safely? I have tried downloading the package online but it doesn't work and found other answers saying use sudo but it's not safe.

Share Improve this question edited Feb 5 at 14:39 phd 95.5k14 gold badges159 silver badges210 bronze badges asked Feb 4 at 0:43 mdotmdot 456 bronze badges 9
  • 2 Please paste your error messages as code-formatted text instead of screenshots. – Anerdw Commented Feb 4 at 0:47
  • 3 It sounds like you are trying to install into the global Python, which needs admin privileges. You need to either 1) create a venv, or 2) use an admin command prompt. – David Commented Feb 4 at 1:08
  • 2 The first error message is not telling you to update pip; it's complaining about a missing package file and then separately giving you a boilerplate notice that there's a new pip version available. – jjc385 Commented Feb 4 at 1:09
  • Do you have admin priviliedges? – Starship Remembers Shadow Commented Feb 4 at 1:38
  • @Starship how do i check if i have admin privileges? – mdot Commented Feb 4 at 1:59
 |  Show 4 more comments

1 Answer 1

Reset to default 0

Try opening your command prompt/terminal with administrator privileges

转载请注明原文地址:http://www.anycun.com/QandA/1744743835a86993.html