[Python-modules-team] Bug#547003: ipython: IPython should use current Python Environment
Wolodja Wentland
wentland at cl.uni-heidelberg.de
Wed Sep 16 19:39:01 UTC 2009
Package: ipython
Version: 0.10-1
Severity: important
Tags: patch
Hi,
IPython should use the Python interpreter in the current environment and
not hardcode /usr/bin/python.
The rationale is that IPython as packaged right now is unusable inside a
customised environment like those created by virtualenv.
--- snip ---
bilen at kinakuta:~$ virtualenv ipython_bug
New python executable in ipython_bug/bin/python
Please make sure you remove any previous custom paths from your /home/user/.pydistutils.cfg file.
Installing setuptools............done.
user at host:~$ cd ipython_bug/
user at host:~/ipython_bug$ source bin/activate
(ipython_bug)user at host:~/ipython_bug$ ipython
...
In [1]: import sys
In [2]: sys.path
Out[2]:
['',
'/usr/bin',
'/usr/lib/python2.5/site-packages/pip-0.4-py2.5.egg',
'/usr/lib/python2.5',
'/usr/lib/python2.5/plat-linux2',
'/usr/lib/python2.5/lib-tk',
'/usr/lib/python2.5/lib-dynload',
'/usr/local/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages/PIL',
'/usr/lib/python2.5/site-packages/gst-0.10',
'/usr/lib/pymodules/python2.5',
'/usr/lib/pymodules/python2.5/gtk-2.0',
'/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode',
'/usr/lib/pymodules/python2.5/IPython/Extensions',
u'/home/user/.ipython']
--- snip ---
I would expect IPython to behave like python:
--- snip ---
(ipython_bug)user at host:~/ipython_bug$ python
Python 2.5.4 (r254:67916, Feb 18 2009, 03:00:47)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/home/user/ipython_bug/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg', '/usr/lib/python2.5/site-packages/pip-0.4-py2.5.egg', '/home/user/ipython_bug/lib/python2.5', '/home/user/ipython_bug/lib/python2.5/plat-linux2', '/home/user/ipython_bug/lib/python2.5/lib-tk', '/home/user/ipython_bug/lib/python2.5/lib-dynload', '/usr/lib/python2.5', '/usr/lib64/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib64/python2.5/lib-tk', '/home/user/ipython_bug/lib/python2.5/site-packages', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/gst-0.10', '/usr/lib/pymodules/python2.5', '/usr/lib/pymodules/python2.5/gtk-2.0', '/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode']
>>> --
--- snip ---
IPython uses the global Python interpreter whereas python uses the one
from the currently configured one, which means that the current environment
is missing in sys.path.
I did *not* specify '--no-site-packages' in the virtualenv call, because
i would have to install IPython in the newly created environment which
will solve the here described problem as well.
This can be easily fixed by replacing #!/usr/bin/python with
#!/usr/bin/env python .
--- snip ---
(ipython_bug)user at host:~/ipython_bug$ ipython
...
In [1]: import sys
In [2]: sys.path
Out[2]:
['',
'/usr/bin',
'/home/user/ipython_bug/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg',
'/usr/lib/python2.5/site-packages/pip-0.4-py2.5.egg',
'/home/user/ipython_bug/lib/python2.5',
'/home/user/ipython_bug/lib/python2.5/plat-linux2',
'/home/user/ipython_bug/lib/python2.5/lib-tk',
'/home/user/ipython_bug/lib/python2.5/lib-dynload',
'/usr/lib/python2.5',
'/usr/lib64/python2.5',
'/usr/lib/python2.5/plat-linux2',
'/usr/lib/python2.5/lib-tk',
'/usr/lib64/python2.5/lib-tk',
'/home/user/ipython_bug/lib/python2.5/site-packages',
'/usr/local/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages/PIL',
'/usr/lib/python2.5/site-packages/gst-0.10',
'/usr/lib/pymodules/python2.5',
'/usr/lib/pymodules/python2.5/gtk-2.0',
'/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode',
'/usr/lib/pymodules/python2.5/IPython/Extensions',
u'/home/user/.ipython']
--- snip ---
The relevant patch is included.
with kind regards
Wolodja Wentland
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.30-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages ipython depends on:
ii python 2.5.4-2 An interactive high-level object-o
ii python-pexpect 2.3-1 Python module for automating inter
ii python-support 1.0.3 automated rebuilding support for P
Versions of packages ipython recommends:
ii global 5.7.1-1 Source code search and browse tool
ii python [python-ctypes] 2.5.4-2 An interactive high-level object-o
ii python-foolscap 0.4.2+dfsg-1 object-capability-based RPC system
ii python-openssl 0.9-1 Python wrapper around the OpenSSL
ii python-twisted-core 8.2.0-3 Event-based framework for internet
ii python-wxgtk2.8 2.8.7.1-1.1 wxWidgets Cross-platform C++ GUI t
pn python-zope.interface <none> (no description available)
Versions of packages ipython suggests:
ii libjs-jquery 1.3.3-2 JavaScript library for dynamic web
ii python-gobject 2.18.0-1 Python bindings for the GObject li
ii python-gtk2 2.14.1-3 Python bindings for the GTK+ widge
ii python-matplotlib 0.98.5.3-2 Python based plotting system in a
ii python-numpy 1:1.3.0-3 Numerical Python adds a fast array
ii python-profiler 2.5.2-1 deterministic profiling of any Pyt
pn python-qt3 | python-qt4 <none> (no description available)
-- no debconf information
-------------- next part --------------
--- /usr/bin/ipython.old 2009-09-16 21:26:48.000000000 +0200
+++ /usr/bin/ipython 2009-09-16 21:27:09.000000000 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""IPython -- An enhanced Interactive Python
More information about the Python-modules-team
mailing list