29๐
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.
17๐
You can also use the command below, it worked for me without sudo
access.
You may also need to modify your PYTHONPATH
environment variable using export
, see this SO answer for more details.
pip install --user virtualenv
- [Django]-Filter Django database for field containing any value in an array
- [Django]-How to iterate through dictionary in a dictionary in django template?
- [Django]-Twisted server crashes unexpectedly while running django
14๐
The general idea is to install virtualenv
itself globaly, i.e. sudo easy_install virtualenv
or sudo pip install virtualenv
, but then create the actual virtual environment (โrun virtualenvโ) locally.
- [Django]-IntegrityError duplicate key value violates unique constraint โ django/postgres
- [Django]-AngularJS + Django Rest Framework + CORS ( CSRF Cookie not showing up in client )
- [Django]-Error loading MySQLdb Module 'Did you install mysqlclient or MySQL-python?'
10๐
http://opensourcehacker.com/2012/09/16/recommended-way-for-sudo-free-installation-of-python-software-with-virtualenv/ suggests the following:
curl -L -o virtualenv.py https://raw.githubusercontent.com/pypa/virtualenv/master/virtualenv.py
python virtualenv.py vvv-venv
. vvv-venv/bin/activate
pip install vvv
It seems to work well. It lets me install https://github.com/miohtama/vvv with pip
.
If you get:
Cannot find sdist setuptools-*.tar.gz
Cannot find sdist pip-*.tar.gz
Try --extra-search-dir
after downloading the tarballs at https://github.com/pypa/virtualenv/tree/develop/virtualenv_support
- [Django]-Django model one foreign key to many tables
- [Django]-Django models ForeignKey on_delete attribute: full meaning?
- [Django]-Django Rest Framework and JSONField
4๐
This worked for me:
pip install --target=$HOME/virtualenv/ virtualenv
cd somewhere/
python $HOME/virtualenv/virtualenv.py env
. env/bin/activate
Now I can pip install
whatever I want (except for everything that needs to compile stuff with gcc and has missing dependencies such as the python development libraries and Python.h
).
- [Django]-What is the difference between null=True and blank=True in Django?
- [Django]-Django โ Get only date from datetime.strptime
- [Django]-Custom error message in Django admin actions
4๐
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)
- [Django]-History of Django's popularity
- [Django]-How to 'clear' the port when restarting django runserver
- [Django]-Django return HttpResponseRedirect to an url with a parameter
2๐
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.
- [Django]-Django Forms: if not valid, show form with error message
- [Django]-How to seed Django project ? โ insert a bunch of data into the project for initialization
- [Django]-<Django object > is not JSON serializable
2๐
I solved my problem installing virtualenv for each user.
python3 -m pip install --user virtualenv
- [Django]-How to work around lack of support for foreign keys across databases in Django
- [Django]-Django cannot import name x
- [Django]-Version number in Django applications
1๐
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
- [Django]-Django: get the first object from a filter query or create
- [Django]-Mixin common fields between serializers in Django Rest Framework
- [Django]-Django admin DoesNotExist at /admin/
1๐
The easiest way I have seen so far is to install Anaconda.
It may be an overkill for you. For me the centOS running on the remote server had only python2.6 installed. Anaconda by default installs everything locally + it is python2.7
curl -O https://repo.continuum.io/archive/Anaconda2-4.2.0-Linux-x86_64.sh
Then
bash Anaconda2-4.2.0-Linux-x86_64.sh
Boom. You have all the packages like numpy and pip installed.
Then if you want virtualenv, just type
pip install virtualenv
- [Django]-Where are the Assertion Methods list from Django TestCase?
- [Django]-Django REST Framework : "This field is required." with required=False and unique_together
- [Django]-Adding model-wide help text to a django model's admin form
1๐
sudo virtualenv -p python myenv1
sudo su
source myenv1/bin/activate
pip install mypackage
this is will install inside virtual environment
- [Django]-Django 1.3.1 compilemessages. Error: sh: msgfmt: command not found
- [Django]-Django and Middleware which uses request.user is always Anonymous
- [Django]-What's the cleanest, simplest-to-get running datepicker in Django?
0๐
The lack of sudo is a common situation in many shared remote server.
It turns out, there is a simpler, lightweight, more secure solution. Just download an official "portable" virtualenv from here: https://bootstrap.pypa.io/virtualenv.pyz
And that is it! You can now run python virtualenv.pyz --help
to your heartโs content.
Official document: https://virtualenv.pypa.io/en/latest/installation.html#via-zipapp
- [Django]-Plug in django-allauth as endpoint in django-rest-framework
- [Django]-Django Queryset and filter() vs get()
- [Django]-Django return redirect() with parameters