On my Linux box the default Python is version 2.7. I installed
bpython system-wide, thus when I launch
bpython, it uses Python 2.7.
How could I have another
bpython that uses Python 3? I would like to have both though. Sometimes I need Python 2, sometimes Python 3, and I would like to use the
bpython shell with them.
bpython in a Python 3 virtual environment. That is, create a Python 3 environment, and install
bpython in it with
bpython installation will use Python 3. Then use the absolute path of this
bpython executable. And no, you don’t have to activate the virt. env. each time you want to use this
In a previous post I showed how to patch
virtualenvwrapper to make it suitable for creating not only Python 2 but Python 3 environments too. Using this patched
virtualenvwrapper, the process looked like this on my machine:
$ cd $ mkdir bpython_python3 $ cd bpython_python3 $ mkvirtualenv bpython_python3 # creates a Python 3 virt. env. (bpython_python3)$ pip install bpython (bpython_python3)$ which bpython /home/jabba/.virtualenvs/bpython_python3/bin/bpython # sample; will be different in your case (bpython_python3)$ deactivate $
I suggest adding the following aliases to your
alias bpy='bpython' alias bpy3='/home/jabba/.virtualenvs/bpython_python3/bin/bpython'
Of course, you need to customize the path for
bpython with Python 2, while “
bpython with Python 3.