Build IPython for Python 3.x

I use IPython as SymPy interface which serves as command-line CAS (Computer Algebra System) application. It’s one of critical software I depend on whenever I study mathematics.

I decided to uprade IPython for Python 3.x because I felt making Python 2.x codes become obsolete.

My Linux workstation runs in AMD 64-bit Devuan 1.0 (Debian 8.x without systemd.)

It was first time for me to install Python package from source build.

Install pip package.
It installs Python module or program.

$ sudo aptitude install python3-pip

The following NEW packages will be installed:
python3-chardet{a} python3-colorama{a} python3-distlib{a} python3-html5lib{a}
python3-pip python3-pkg-resources{a} python3-requests{a}
python3-setuptools{a}
python3-six{a} python3-urllib3{a}
The following packages are RECOMMENDED but will NOT be installed:
python3-dev python3-wheel
0 packages upgraded, 10 newly installed, 0 to remove and 17 not
upgraded.
Need to get 842 kB of archives. After unpacking 3,737 kB will be used.

$ sudo pip3 --version
pip 1.5.6 from /usr/lib/python3/dist-packages (python 3.4)

Source build installation of IPython
It connects to a python repository and download the ipython source file.
$ sudo pip3 install ipython

...
Running setup.py install for pexpect

Running setup.py install for pickleshare

Running setup.py install for ptyprocess

Successfully installed ipython simplegeneric pexpect traitlets pickleshare decorator ptyprocess ipython-genutils path.py
Cleaning up...

If the installation is failed, it saves /root/.pip/pip.log

When I started IPython 4.0.1, it complained matplotlib was missing, which is the plotting library.

Install matplotlib module

The first attempt failed due to two missing libraries: freetype and png.

After multiple installation failure, slow download speed of the package file forced me to download the package file and use it over and over.

Only download matplotlib package file in ~/Admin directory.
$ sudo pip3 install -d ~/Admin matplotlib

I ran the below command several times until I successfully built matplotlib module.

$ sudo pip3 install ./matplotlib-1.5.0.tar.gz


$ sudo pip3 install matplotlib

Downloading/unpacking matplotlib
Downloading matplotlib-1.5.0.tar.gz (54.0MB): 54.0MB downloaded
Running setup.py (path:/tmp/pip-build-v30xilsb/matplotlib/setup.py) egg_info for package matplotlib
======================================================================
Edit setup.cfg to change the build options

BUILDING MATPLOTLIB
matplotlib: yes [1.5.0]
python: yes [3.4.3+ (default, Oct 10 2015, 09:15:38) [GCC
5.2.1 20151028]]
platform: yes [linux]

======================================================================
* The following required packages can not be built:
* freetype, png

Install libfreetype6-dev


$ sudo aptitude install libfreetype6-dev
The following NEW packages will be installed:
libfreetype6-dev{b} libpng12-dev{a} zlib1g-dev{a}
0 packages upgraded, 3 newly installed, 0 to remove and 17 not upgraded.
Need to get 1,094 kB of archives. After unpacking 4,706 kB will be used.
The following packages have unmet dependencies:
libfreetype6-dev : Depends: libfreetype6 (= 2.5.2-3) but 2.6-2 is installed.
The following actions will resolve these dependencies:

Keep the following packages at their current version:
1) libfreetype6-dev [Not Installed]

Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

Downgrade the following packages:
1) libfreetype6 [2.6-2 (now) -> 2.5.2-3 (stable)]

I did not install libpng packages because in second attempt, it did not report missing png library. And it reported missing fortran compiler.

Install gfortran package

$ sudo aptitude install gfortran

In the third attempt of installion, during numpy module compilation, missing Python.h file terminated the build process.
It turned out libpython3.4-dev package contains Python.h header file.

On the net Debian or Ubuntu users recommended python3-dev package so I installed it that included libpython3-dev.

$ aptitude install python3-dev

Downgrade the following packages:
1) libexpat1 [2.1.0-7 (now) -> 2.1.0-6+deb8u1 (stable)]
2) libpython3-stdlib [3.4.3-7 (now) -> 3.4.2-2 (stable)]
3) libpython3.4-minimal [3.4.3-10+b1 (now) -> 3.4.2-1 (stable)]
4) libpython3.4-stdlib [3.4.3-10+b1 (now) -> 3.4.2-1 (stable)]
5) python3 [3.4.3-7 (now) -> 3.4.2-2 (stable)]
6) python3-minimal [3.4.3-7 (now) -> 3.4.2-2 (stable)]
7) python3.4 [3.4.3-10+b1 (now) -> 3.4.2-1 (stable)]
8) python3.4-minimal [3.4.3-10+b1 (now) -> 3.4.2-1 (stable)]

Accept this solution? [Y/n/q/?] Y
The following packages will be DOWNGRADED:
libexpat1 libpython3-stdlib libpython3.4-minimal libpython3.4-stdlib python3
python3-minimal python3.4 python3.4-minimal
The following NEW packages will be installed:
libexpat1-dev{a} libpython3-dev{a} libpython3.4{a} libpython3.4-dev{a}
python3-dev python3.4-dev{a}
0 packages upgraded, 6 newly installed, 8 downgraded, 0 to remove and 17 not upgraded.
Need to get 46.0 MB of archives. After unpacking 56.1 MB will be used.

Finally, I ran IPython test program to make sure its integrity and features. Each test discovered missing module that IPython requires: nose, pygments, ipykernel, testpath. Note that ipykernel installs three additional modules, jupyter-client, pyzmq, and jupyter-core.


$ sudo pip3 install nose
Downloading/unpacking nose
Downloading nose-1.3.7-py3-none-any.whl (154kB): 154kB downloaded
Installing collected packages: nose
Successfully installed nose
Cleaning up...

$ sudo pip3 install pygments
Downloading/unpacking pygments
Downloading Pygments-2.0.2-py3-none-any.whl (672kB): 672kB downloaded
Installing collected packages: pygments
Successfully installed pygments
Cleaning up...

$ sudo pip3 install ipykernel
Downloading/unpacking ipykernel
Downloading ipykernel-4.2.1-py2.py3-none-any.whl (90kB): 90kB downloaded
Requirement already satisfied (use --upgrade to upgrade): traitlets in /usr/local/lib/python3.4/dist-packages (from ipykernel)
Downloading/unpacking jupyter-client (from ipykernel)
Downloading jupyter_client-4.1.1-py2.py3-none-any.whl (70kB): 70kB downloaded
Requirement already satisfied (use --upgrade to upgrade): ipython>=4.0.0 in /usr/local/lib/python3.4/dist-packages (from ipykernel)
Downloading/unpacking pyzmq>=13 (from jupyter-client->ipykernel)
Downloading pyzmq-15.1.0.tar.gz (1.1MB): 1.1MB downloaded
Running setup.py (path:/tmp/pip-build-njsaza8r/pyzmq/setup.py) egg_info for package pyzmq
...snip...
warning: no previously-included files matching 'Makefile.in' found anywhere in distribution
Successfully installed ipykernel jupyter-client pyzmq jupyter-core
Cleaning up...

$ sudo pip3 install testpath
Downloading/unpacking testpath
Downloading testpath-0.2-py2.py3-none-any.whl
Installing collected packages: testpath
Successfully installed testpath
Cleaning up...

Test command I ran

$ iptest 2>&1 | tee iptest3.log

It stores error messages and screen output to iptest3.log file.
1 is standard output discriptor normally means text in the termal.
2 is standard error discriptor.

All seven tests passed.

Test suite completed for system with the following information:
IPython version: 4.0.1
IPython commit : 03b6385 (installation)
IPython package: /usr/local/lib/python3.4/dist-packages/IPython
Python version : 3.4.2 (default, Oct 8 2014, 10:45:20) [GCC 4.9.1]
sys.executable : /usr/bin/python3
Platform : Linux-3.16.0-4-amd64-x86_64-with-debian-8.2

Tools and libraries available at test time:
matplotlib pygments sqlite3

Status: OK (7 test groups). Took 46.269s.


Test group: core
.......................................................................S..S...........
......................................................................................
.....................................................................................S
................S.........................S.
KeyboardInterrupt
....S............................................S............S../usr/local/lib/python
3.4/dist-packages/IPython/core/magics/extension.py:47: UserWarning: %install_ext` is d
eprecated, please distribute your extension(s)as a python packages.
"as a python packages.", UserWarning)
.S....................................................................................
..............S................S.....................S............
----------------------------------------------------------------------
Ran 519 tests in 17.019s

OK (SKIP=12)

Test group: extensions
..
----------------------------------------------------------------------
Ran 2 tests in 0.007s

OK

Test group: lib
...........................S..........................................
----------------------------------------------------------------------
Ran 70 tests in 2.073s

OK (SKIP=1)

Test group: terminal
........S..........
----------------------------------------------------------------------
Ran 19 tests in 5.038s

OK (SKIP=1)

Test group: testing
..S..S............S..
----------------------------------------------------------------------
Ran 21 tests in 3.476s

OK (SKIP=3)

Test group: utils
...............................................................................S......
..SSS...S.....S...............S..S...........................................
----------------------------------------------------------------------
Ran 163 tests in 1.390s

OK (SKIP=8)

Test group: autoreload
..
----------------------------------------------------------------------
Ran 2 tests in 6.387s

OK

______________________________________________________________________
Test suite completed for system with the following information:
IPython version: 4.0.1
IPython commit : 03b6385 (installation)
IPython package: /usr/local/lib/python3.4/dist-packages/IPython
Python version : 3.4.2 (default, Oct 8 2014, 10:45:20) [GCC 4.9.1]
sys.executable : /usr/bin/python3
Platform : Linux-3.16.0-4-amd64-x86_64-with-debian-8.2

Tools and libraries available at test time:
matplotlib pygments sqlite3

Status: OK (7 test groups). Took 46.269s.

One of error messges that I encountered by iptest.

======================================================================
ERROR: IPython.core.tests.test_display.test_set_matplotlib_close
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/usr/local/lib/python3.4/dist-packages/IPython/testing/decorators.py", line 20
8, in skipper_func
return f(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/IPython/core/tests/test_display.py", li
ne 68, in test_set_matplotlib_close
cfg = _get_inline_config()
File "/usr/local/lib/python3.4/dist-packages/IPython/core/tests/test_display.py", li
ne 63, in _get_inline_config
from ipykernel.pylab.config import InlineBackend
ImportError: No module named 'ipykernel'

About janpenguin

Email: janpenguin [at] riseup [dot] net Every content on the blog is made by Free and Open Source Software in GNU/Linux.
This entry was posted in GNU/Linux, Python and tagged , , , , , , , , , . Bookmark the permalink.

One Response to Build IPython for Python 3.x

  1. janpenguin says:

    Using Bash To Output To Screen And File At The Same Time
    http://disq.us/8vninm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s