Lately I’ve been experimenting a bit with Python and several frameworks, mostly for getting up to speed and having fun. Most of my work no longer implies programming on a daily basis but I do miss it and sometimes I spend some of my free time programming because of that.
Usually, the first challenge is to setup the development environment. A sane one. Regarding the python ecosystem, that means using a version manager (such as py-env, that replaced pythonbrew), virtualenv and possibly virtualenvwrapper. All of this may be trivial using bash or even z-shell, but I’m using fish shell for a few months and I’d like to keep it that way. Plus, it’s a challenge.
So, here’s what I’ve found that works on mavericks:
First off, enable pyenv support on fish shell. There may be other ways to do so, but I’m currently using oh-my-fish, a clone of the popular oh-my-zsh. This project is easily installed and contains plugins you can enable by editing “~/.config/fish/config.fish“ to include the line:
set fish_plugins brew django pyenv python # other plugins
This sets the ground for pyenv to work nicely. Install py-env using homebrew:
brew install pyenv
From this point onwards, you may choose to install virtualenv manually or use pyenv-virtualenv, as suggested by the author. I’ve done this using homebrew again, using the latest development release:
brew install —HEAD pyenv-virtualenv
..and everything works, so far.
Personally, I find the pyenv / pyenv-virutalenv combo a bit confusing, because the virtualenvs aren’t totally scoped to python versions. For instance, you can’t create two virtualenvs with the same name, even if they “belong” to different python versions (say, 2.7.3 and 3.3.2). Also, if you type
you get all python versions AND virtualenvs mixed. Example:
If you want to use a virtualenv, you have to treat it as any other python version, using
pyenv local django # the same way you would type pyenv local 2.7.3
Confusing, right? Especially coming from rvm or rbenv. Anyway, it works!
I have also tried installing pyenv-virtualenvwrapper but couldn’t make it work :( I think that’s because virtualenvwrapper is not compatible with fish shell. Anyway, I’ve found an interesting project called virtualfish which seems to provide that functionality. I might give it a go sometime.
Well, I hope it helps!