如何在不使用sudo的情况下安装virtualenv? [英] How to install virtualenv without using sudo?

查看:158
本文介绍了如何在不使用sudo的情况下安装virtualenv?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 easy_install pip

我在我的 Linux Mint 12 上有很多错误,我刚刚重新安装,我想从头再次安装所有内容。

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:


停止使用su和sudo来运行virtualenv。

你需要运行virtualenv作为您的普通用户。

您已经使用sudo创建了virtualenv,这就是为什么您收到这些错误。

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.

所以如何安装 virtualenv 而不使用 sudo ?可以使用 pip easy_install 而不使用 sudo ?或者还有另一种方式吗?

So how to install virtualenv without using sudo? Can i use pipor easy_install without using sudo? Or is there another way?

推荐答案

此解决方案适用于系统范围内没有virtualenv可用的情况,您无法成为根安装virtualenv。当我为python开发或部署设置debian时,我总是apt-get install python-virtualenv。比起下面指出的引导来说更方便。但没有root权力,可能是要走的路:

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.

阅读: http://peak.telecommunity.com/DevCenter/EasyInstall#creating- a-virtual-python

本质上,您可以在unix环境中的主目录中执行此操作:

In essence you would do this in your home directory in a unix environment:

鉴于您的python是2.6版本

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

可能有o的空间ptimization。我不喜欢'本地'的路径。只是bin和lib会很好。但是它的工作就是这样。

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屋!

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