如何避免“权限被拒绝"?当与virtualenv一起使用pip时 [英] How to avoid "Permission denied" when using pip with virtualenv

查看:110
本文介绍了如何避免“权限被拒绝"?当与virtualenv一起使用pip时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Ubuntu计算机上的虚拟环境中使用pip部署Python软件包,但是遇到与权限相关的问题.例如:

(TestVirtualEnv)test@testServer:~$ pip install markdown2

终止于:

错误:无法创建'/home/test/virtualenvs/TestVirtualEnv/lib/python3.3/site-packages/markdown2.py':权限被拒绝

我不能sudo,因为它将在全局安装该软件包,而不是在虚拟环境中安装.我chown ed site-packages; ls仅显示与easy_installpipsetuptools相关的目录,而没有与Markdown相关的目录.

如何在具有pip的虚拟环境中部署程序包而不会遇到与权限相关的错误?

解决方案

virtualenv当您将virtualenv创建为sudo,然后在virtualenv中没有sudo的情况下运行时,可能会发生权限问题.

从您的问题的评论中可以发现,这里的解决方案是创建而不使用sudovirtualenv,以便能够工作(尤其是写)没有sudo.

I attempt to deploy a Python package with pip in a virtual environment on an Ubuntu machine, but encounter a permission-related issue. For example:

(TestVirtualEnv)test@testServer:~$ pip install markdown2

terminates by:

error: could not create '/home/test/virtualenvs/TestVirtualEnv/lib/python3.3/site-packages/markdown2.py': Permission denied

I can't sudo, since it will install the package globally, and not within the virtual environment. I chowned site-packages; ls shows only directories related to easy_install, pip and setuptools, and nothing related to Markdown.

How to deploy a package in a virtual environment with pip without encountering permission-related errors?

解决方案

virtualenv permission problems might occur when you create the virtualenv as sudo and then operate without sudo in the virtualenv.

As found out in your question's comment, the solution here is to create the virtualenv without sudo to be able to work (esp. write) in it without sudo.

这篇关于如何避免“权限被拒绝"?当与virtualenv一起使用pip时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆