以 root 身份停止 PyCharm 运行 pip

Stop PyCharm running pip as root

我需要在 PyCharm 中创建 Django 项目。我正在使用解释器 3.6.3 at /usr/bin/python3.6。创建后,我收到消息 Authentication is needed to run /usr/bin/python3.6 as the superuser。我点击了取消,我得到了:

Executed command: pip install Django
Error occurred: Non-zero exit code (126)
Proposed solution:
   Try to run this command from the system terminal. Make sure that you use correct version of 'pip' installed for your Python interpreter located at '/usr/bin/python3.6'.
Command output:
   Error executing command as another user: Request dismissed

但是,如果我提供我的密码并单击“身份验证”,那么 pip、pip3 和 virtualenv 将被破坏,因为 IDE 正在尝试以 root 身份安装 Django。我怎样才能以 root 身份停止 PyCharm 运行 pip?

要让 PyCharm 更好地使用虚拟环境,请执行以下操作:

1 - 使用 shell 创建 virtualenv

  • 创建虚拟环境:virtualenv <virtualEnvName>
  • 激活虚拟环境:. <virtualEnvName>/bin/activate
  • 下载 包到虚拟环境:pip install <pkg>

2 - 告诉 PyCharm 你创建的 virtualenv

  • 在PyCharm中打开项目File > Open > urProject
  • select 来自 virtualenv 的解释器PyCharm Community Edition > Preferences > Project > Project Interpreter