I\'m trying to set up a virtualenv on Ubuntu 10.04 with Python 2.6.5 but having some issues.
After having installed virtualenv and virtualenv wrapper with pip, I\'m
This issue already has several answers, but I want to share my solution, in case it helps the next person.
Where I run the command matters. I was running the virtualenv env command inside the /vagrant shared folder. That was my mistake. When I cd back to my HOME dir, then run virtualenv env, everything works fine.
I haven't run across this particular problem, but I've personally switched from using virtualenv
to pythonbrew. pythonbrew
is a different solution to the same problem; it works more like rvm in the Ruby community: It builds entirely self-contained versions of Python, from scratch, under $HOME/.pythonbrew
; then, it provides shell functions that allow you to switch easily from one to another (editing the path for you, etc.). It's not as lightweight as virtualenv
, but it also doesn't piggyback on the system Python, so the whole symlink issue goes away. You can also install multiple Python versions, even if they're not installed in the base system.
Your mileage may vary, of course, but pythonbrew
has been working well for me.
This error occurs because the virtualenv.py file you are using is not compatible with the python version that you are using.. For python2.7 you need to downalod the binaries from the virtualenv.org site and then compile them using
python setup.py install
after the installation use the installed binary(not the virtualenv.py file) to create virtual environment by
virtualenv --no-site-packages <path to virtual env directory>/env/
Seems like its been a bit since you asked this. Virtualbox's file driver for the /vagrant directory cannot recognize symbolic links which virtualenv uses a lot.
This can be best demonstrated with a simple
mybox:/vagrant$ ln -s ~/.bashrc
ln: failed to create symbolic link ./.bashrc': Protocol error`
Update:
Because of vagrant's incompatibility with symbolic links & virtualenv, my vagrant boxes/instances were task/project specific ( only 1 virtualenv). So in the vagrant host side/instance folder I would keep a short script to install python & virtualenv, then do
pip install -r /vagrant/requirement
Further documentation can be found here. https://docs.vagrantup.com/v2/provisioning/basic_usage.html
with the appropriate bash if
checks ( does python exist, does /home/vagrant/env exist ), you can provision your box once and then append a call to activate your ~/env install so that when you login, your already setup and ready to go.