How to install virtualenv without using sudo?

后端 未结 10 520
暖寄归人
暖寄归人 2020-11-30 23:51

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 everythin

相关标签:
10条回答
  • 2020-12-01 00:22

    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.

    0 讨论(0)
  • 2020-12-01 00:22

    You might want to consider using Anaconda. It's a full-fledged Python distribution, that lives in a folder in e.g. your home directory. No sudo is necessary at any point and you get most of the popular packages.

    $ wget https://.../Anaconda2-2.5.0-Linux-x86_64.sh # check the website for the exact URL, it can change
    $ bash Anaconda2-2.5.0-Linux-x86_64.sh
    $ conda install virtualenv
    
    0 讨论(0)
  • 2020-12-01 00:27

    I've created a "portable" version of virtualenv.

    wget https://bitbucket.org/techtonik/locally/raw/tip/06.get-virtualenv.py
    python 06.get-virtualenv.py
    

    It downloads virtualenv.py script with dependencies into .locally subdir and executes it from there. Once that's done, the script with .locally/ subdir can be copied anywhere.

    0 讨论(0)
  • 2020-12-01 00:27

    Basically the idea is to install virtualenv (or any other python package) into ${HOME}/.local. This is the most appropriate location since it is included into python path by default (and not only Python).

    That you do by pip3 install virtualenv --prefix=${HOME}/.local (you may need to expand ${HOME}). Make sure that you have export PATH=${HOME}/.local/bin:${PATH} in your ~/.profile (you may need to source ~/.profile it if just added)

    0 讨论(0)
提交回复
热议问题