由于环境错误而无法安装软件包:[Errno 13] Pip安装Pytest

时间:2019-01-12 12:36:07

标签: macos terminal pip pytest

尝试设置pytest时遇到问题。当我跑步时:

pip install pytest pytest-cache

我收到此错误消息:

  

由于环境错误而无法安装软件包:[Errno 13]权限被拒绝:'/Library/Python/2.7/site-packages/apipkg'   考虑使用--user选项或检查权限。

1 个答案:

答案 0 :(得分:0)

根据错误消息,您无权在Library目录中进行安装,并且可以使用--user选项进行安装。

pip install pytest pytest-cache --user

$ pip install --help

--user    Install to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%\Python on Windows. (See the Python documentation for site.USER_BASE for
                              full details.)

或者,如果您具有sudo访问权限,则可以使用sudo安装在Library目录中

sudo pip install pytest pytest-cache.

一种推荐的替代方法是使用virtualenv

相关问题