简体   繁体   English

为什么我不能在 Windows 10 上使用 pip 安装 python 包?

[英]Why can't I install python packages with pip on windows 10?

I have had this running battle with pip on my windows 10 PC ever since I tried to upgrade it.自从我尝试升级它以来,我一直在我的 Windows 10 PC 上与 pip 进行这场战斗。 I tried to upgrade it with pip upgrade .我尝试使用pip upgrade对其进行升级。 After that, pip has stopped working.之后,pip 停止工作。 I wanted to install Pygame on my pc with pip install pygame and I got the following error message about my operating system:我想用pip install pygame在我的电脑上安装 Pygame,我收到以下关于我的操作系统的错误消息:

ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Python310\\Include\\pygame'
Consider using the `--user` option or check the permissions.

I get the same error message anytime I try to install any python package on my pc.每当我尝试在我的电脑上安装任何 python 包时,我都会收到相同的错误消息。 Please what can I do to correct this problem?请问我能做些什么来纠正这个问题?

Solution #1解决方案#1

  1. Run Windows PowerShell as Admin以管理员身份运行 Windows PowerShell
  2. Run the pip install command to install the python module or upgrade the pip.运行 pip install 命令安装 python 模块或升级 pip。

---- OR ---- - - 或者 - -

Solution #2解决方案#2

Run Pip Install with --user flag使用--user标志运行 Pip 安装

Command: python -m pip install --upgrade pip --user命令: python -m pip install --upgrade pip --user

Just type the command you want execute with the user permission, if you don't want to change the permission:如果您不想更改权限,只需键入要使用用户权限执行的命令:

pip install pygame --user

and if you want to change user permission then follow these steps:如果您想更改用户权限,请按照以下步骤操作:

Just change the access permission , where the particular package is going to install.只需更改要安装特定软件包的访问权限即可。

On Windows 10 :Windows 10上:

  • Go to the installation folder.转到安装文件夹。 For example: C:\Program Files (x86)\Python37例如: C:\Program Files (x86)\Python37
  • Right click on python installation root and click Properties .右键单击 python 安装根并单击Properties In this case, the Python37 folder.在这种情况下, Python37文件夹。
  • Go to the Security tab, click Edit button and allow full control for the Users group.转到Security选项卡,单击Edit按钮并允许对用户组进行完全控制 Remember to click Apply .记得点击Apply
  • Try to install the package again.尝试再次安装该软件包。

Below is an example of desired settings:以下是所需设置的示例: 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM