0

我需要在 PyCharm 中创建 Django 项目。我正在使用解释器3.6.3 at /usr/bin/python3.6。创建它后,我收到了 message 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

但是,如果我提供密码并单击 Authenticate,则 pip、pip3 和 virtualenv 将被破坏,因为 IDE 正在尝试以 root 身份安装 Django。如何停止 PyCharm 以 root 身份运行 pip?

4

1 回答 1

0

要使 PyCharm 与虚拟环境配合得很好,请执行以下操作:

1 - 使用 shell 创建 virtualenv

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

2 - 告诉 PyCharm 你创建的 virtualenv

  • 在 PyCharm 中打开项目:File > Open > urProject
  • 从 virtualenv 中选择解释器:PyCharm Community Edition > Preferences > Project > Project Interpreter
于 2017-11-26T03:35:00.733 回答