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

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

问题描述

我有 easy_installpip.

我的 Linux Mint 12 有很多错误,我刚刚重新安装了它,我想从头开始重新安装所有东西.

这是其中之一我的错误.我在那里收到了一个有趣的答案:

<块引用>

停止使用 su 和 sudo 运行 virtualenv.
您需要以普通用户身份运行 virtualenv.
您已经使用 sudo 创建了 virtualenv,这就是您收到这些错误的原因.

那么如何在不使用sudo的情况下安装virtualenv?我可以在不使用 sudo 的情况下使用 pipeasy_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 路径.只需 binlib 就好了.但它完成了它的工作.

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

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