如何在不使用 sudo 的情况下安装 virtualenv? [英] How to install virtualenv without using sudo?
问题描述
我有 easy_install
和 pip
.
我的 Linux Mint 12 有很多错误,我刚刚重新安装了它,我想从头开始重新安装所有东西.
<块引用>停止使用 su 和 sudo 运行 virtualenv.
您需要以普通用户身份运行 virtualenv.
您已经使用 sudo 创建了 virtualenv,这就是您收到这些错误的原因.
那么如何在不使用sudo
的情况下安装virtualenv
?我可以在不使用 sudo
的情况下使用 pip
或 easy_install
吗?或者有其他方法吗?
此解决方案适用于在系统范围内没有 virtualenv
可用且您无法成为 root 来安装 virtualenv代码>.当我为 python 开发或部署设置 debian 时,我总是
apt-get install python-virtualenv
.使用它比做下面指出的引导程序更方便.但是没有root权限,它可能是要走的路:
有一个引导机制可以让你继续前进.
阅读:http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python
本质上,您将在 unix 环境中的主目录中执行此操作:
鉴于您的 python 是 2.6 版
<前>$ mkdir ~/bin$ mkdir -p ~/lib/python2.6$ mkdir -p ~/local/lib/python2.6/dist-packages$ wget http://peak.telecommunity.com/dist/virtual-python.py$ python virtual-python.py --no-site-packages$ wget http://peak.telecommunity.com/dist/ez_setup.py$ ~/bin/python ez_setup.py$ ~/local/bin/easy_install virtualenv$ ~/local/bin/virtualenv --no-site-packages thereyouare可能还有优化空间.我不喜欢 local
路径.只需 bin
和 lib
就好了.但它完成了它的工作.
I have easy_install
and pip
.
I had many errors on my Linux Mint 12, I just re-installed it and I want to install everything from scratch again.
This is one of the errors that I had. I received an interesting answer there:
Stop using su and sudo to run virtualenv.
You need to run virtualenv as your normal user.
You have created the virtualenv with sudo which is why you are getting these errors.
So how to install virtualenv
without using sudo
? Can i use pip
or easy_install
without using sudo
? Or is there another way?
This solution is suitable in cases where no virtualenv
is available system wide and you can not become root to install virtualenv
. When I set up a debian for python development or deployment I always apt-get install python-virtualenv
. It is more convenient to have it around than to do the bootstrap pointed out below. But without root power it may be the the way to go:
There is a bootstrap mechanism that should get you going.
Read: http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python
In essence you would do this in your home directory in a unix environment:
Given your python is version 2.6
$ mkdir ~/bin $ mkdir -p ~/lib/python2.6 $ mkdir -p ~/local/lib/python2.6/dist-packages $ wget http://peak.telecommunity.com/dist/virtual-python.py $ python virtual-python.py --no-site-packages $ wget http://peak.telecommunity.com/dist/ez_setup.py $ ~/bin/python ez_setup.py $ ~/local/bin/easy_install virtualenv $ ~/local/bin/virtualenv --no-site-packages thereyouare
There may be room for optimization. I don't like the local
path. Just bin
and lib
would be nice. But it does its job.
这篇关于如何在不使用 sudo 的情况下安装 virtualenv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!