Issue
I have my Ubuntu 12.04 system set up so that I can create a virtualenv with either Python 2.7 or Python 3.3, and run IPython Notebook. The problem is, I don't know exactly what I did to my system to make this possible. I am trying to help someone else get their system set up the same way, and I'm not sure what packages I am missing.
On my system I can run the following commands to get IPython Notebook running in a virtualenv:
~$ mkdir test_ipython3.3
~$ cd test_ipython3.3
~/test_ipython3.3$ virtualenv -p python3.3 venv
~/test_ipython3.3$ source venv/bin/activate
(venv)~/test_ipython3.3$ pip install ipython[all]==1.1.0
I can do the same set of commands with virtualenv -p python2.7 venv
, and have an almost identical environment except it runs Python 2.7.
I am trying to get a 12.04 installation on virtualbox set up so that I can run these commands successfully as well, but I keep failing. After building a clean Ubuntu 12.04 machine in virtualbox, I do the following:
# Update machine:
sudo apt-get update
sudo apt-get dist-upgrade
# Install Python 3.3:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python3.3
# Install virtualenv
sudo apt-get install python-pip
sudo pip install pip --upgrade
sudo pip install virtualenv
# Install necessary packages:
sudo apt-get install python-dev python3.3-dev libzmq-dev
# Build a venv, using Python 2.7, which works:
~$ mkdir test_ipython2.7
~$ cd test_ipython2.7
~/test_ipython2.7$ virtualenv -p python2.7 venv
~/test_ipython2.7$ source venv/bin/activate
(venv)~/test_ipython2.7$ pip install ipython[all]==1.1.0
(venv)~/test_ipython2.7$ ipython notebook
# Works, opening an ipynb that runs Python 3.3
# Build a venv, using Python 3.3, which fails:
~$ mkdir test_ipython3.3
~$ cd test_ipython3.3
~/test_ipython3.3$ virtualenv -p python3.3 venv
~/test_ipython3.3$ source venv/bin/activate
(venv)~/test_ipython3.3$ pip install ipython[all]==1.1.0
(venv)~/test_ipython3.3$ ipython notebook
# Fails, says that ipython is not installed, despite having reported otherwise
After trying to install ipython in the 3.3 virtualenv, I get a message that ipython and a number of supporting packages have been installed successfully. But when I try to run ipython or ipython notebook, I get a message that ipython is not installed. Watching the install process, and scrolling back through the output, I can't find any obvious failures. I even installed zmq from source, so I have zmq 4.0.3 installed, which ipython is finding during its installation.
Can anyone spot where I am going wrong?
Solution
IPython 1.x creates scripts with a '3' suffix when installed with Python 3, to avoid conflict with IPython installed with Python 2, so the command you want is:
ipython3 notebook
In current development IPython (will be 2.0), this behavior is changed somewhat, where IPython installs both the non-suffix and the suffix entry points (ipython
and ipython3
on Python 3, ipython
and ipython2
on Python 2), following the pattern established by other packages, such as nose.
I'm still quite curious about the best way to install ipython when you want access to a 2.7 interpreter sometimes, and a 3.3 interpreter other times.
There are two ways to deal with this:
The first is to create an ipython
script somewhere very high priority in your PATH (I use ~/bin
),
with the contents:
#!/usr/bin/env python
import IPython
IPython.start_ipython()
This will use the current python on your PATH, no matter what, so when you activate a Python 3 env, ipython will use that, etc.
The second is to just use:
python -m IPython
or
python3 -m IPython
which is the same as typing ipython
, but you are specifying the interpreter to use explicitly, so there can be no doubt about what Python is in use.
Answered By - minrk
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.