IPython Notebook in a virtualenv, using Python 3.3

japhyr

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?

minrk

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Using Python 3 in virtualenv

From Dev

Anaconda: Python 3 and 2 in IPython/Jupyter Notebook

From Java

Using both Python 2.x and Python 3.x in IPython Notebook

From Dev

How to visualize a graph using d3.js in iPython notebook?

From Dev

How to install pyzmq for iPython Notebook in a Python 3 virtual environment?

From Dev

Install several new versions of Python3.x on an IPython notebook

From Dev

Python 3 virtualenv problems

From Dev

Ipython notebook 3 disables seaborn settings

From Dev

IPython/Jupyter notebook 3 - hide headers by default

From Dev

ipython3 - no module named notebook

From Dev

I am using jupyter notebook, ipython 3 on windows. Whenever i am starting my python 3, i get the "Kernel Dead" message

From Dev

Have IPython run using Python 3 and not Python 2

From Dev

Virtualenv with only Python3

From Dev

Switching to ipython for python3?

From Java

How can I see function arguments in IPython Notebook Server 3?

From Dev

Displaying rotatable 3D plots in IPython or Jupyter Notebook

From Dev

Creating unique comboboxes in tabs of a notebook using tkinter and python 3

From Java

Execute Python script within Jupyter notebook using a specific virtualenv

From Dev

Jupyter Notebook - Python 3 kernel

From Dev

Using virtualenv with Sublime Text 3 and SublimeREPL

From Dev

iPython 3 Notebook raising ImportError: No module named 'IPython.frontend.html'

From Dev

Using IPython console along side IPython notebook

From Dev

Can not create a "notebook" using ipython Notebook

From Dev

Is this possible > Sublime3 + a python linter + virtualenv?

From Dev

Install pysqlite in virtualenv with python3 support

From Dev

Should I install python 3 in my virtualenv?

From Dev

Virtualenv - Python 3 - Ubuntu 14.04 64 bit

From Dev

Should I install python 3 in my virtualenv?

From Dev

the '-' in command 'virtualenv -p python3 . '

Related Related

  1. 1

    Using Python 3 in virtualenv

  2. 2

    Anaconda: Python 3 and 2 in IPython/Jupyter Notebook

  3. 3

    Using both Python 2.x and Python 3.x in IPython Notebook

  4. 4

    How to visualize a graph using d3.js in iPython notebook?

  5. 5

    How to install pyzmq for iPython Notebook in a Python 3 virtual environment?

  6. 6

    Install several new versions of Python3.x on an IPython notebook

  7. 7

    Python 3 virtualenv problems

  8. 8

    Ipython notebook 3 disables seaborn settings

  9. 9

    IPython/Jupyter notebook 3 - hide headers by default

  10. 10

    ipython3 - no module named notebook

  11. 11

    I am using jupyter notebook, ipython 3 on windows. Whenever i am starting my python 3, i get the "Kernel Dead" message

  12. 12

    Have IPython run using Python 3 and not Python 2

  13. 13

    Virtualenv with only Python3

  14. 14

    Switching to ipython for python3?

  15. 15

    How can I see function arguments in IPython Notebook Server 3?

  16. 16

    Displaying rotatable 3D plots in IPython or Jupyter Notebook

  17. 17

    Creating unique comboboxes in tabs of a notebook using tkinter and python 3

  18. 18

    Execute Python script within Jupyter notebook using a specific virtualenv

  19. 19

    Jupyter Notebook - Python 3 kernel

  20. 20

    Using virtualenv with Sublime Text 3 and SublimeREPL

  21. 21

    iPython 3 Notebook raising ImportError: No module named 'IPython.frontend.html'

  22. 22

    Using IPython console along side IPython notebook

  23. 23

    Can not create a "notebook" using ipython Notebook

  24. 24

    Is this possible > Sublime3 + a python linter + virtualenv?

  25. 25

    Install pysqlite in virtualenv with python3 support

  26. 26

    Should I install python 3 in my virtualenv?

  27. 27

    Virtualenv - Python 3 - Ubuntu 14.04 64 bit

  28. 28

    Should I install python 3 in my virtualenv?

  29. 29

    the '-' in command 'virtualenv -p python3 . '

HotTag

Archive