jrjohansson / version_information

IPython magic command for showing version information for dependency modules in a notebook.
54 stars 17 forks source link

Doesn't work in IPython console #6

Open thorstenkampe opened 9 years ago

thorstenkampe commented 9 years ago

In ipython_config I have

ISA = config.InteractiveShellApp
ISA.extensions = ['version_information']
ISA.exec_lines = ['%version_information']

In IPython console I get

<version_information.VersionInformation object at 0x0000000004A474E0>

In QtConsole I get

Software Version
Python   3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)]
IPython  2.3.0
OS       nt [win32]
Sun Oct 05 01:24:50 2014 Mitteleuropäische Sommerzeit

By the way: there are much nicer and better ways to output the operating system than os. Namely the platform module.

jrjohansson commented 9 years ago

Thanks for reporting your problem. However, it seems to work for me in the qtconsole. After adding

config = get_config()
ISA = config.InteractiveShellApp
ISA.extensions = ['version_information']
ISA.exec_lines = ['%version_information']

I get the following output when starting ipython's qtconsole:

$ ipython qtconsole
....
Software     Version
Python        3.4.1 (default, Sep 20 2014, 19:44:17) [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)]
IPython       2.2.0
OS              posix [darwin]
Sun Oct 05 10:36:08 2014 JST

Are you using the latest version of the version_information extension?

I'm aware that the platform module gives more detailed os information. How would you suggest displaying the os version, and in what sense is it much nicer than what the os module give?

thorstenkampe commented 9 years ago

There seems to be a misunderstanding: version_information works fine for me in QtConsole. Just not in the console version of IPython.

I used...

%install_ext http://raw.github.com/jrjohansson/version_information/master/version_information.py

...yesterday evening, so I suppose, it's the latest version.

thorstenkampe commented 9 years ago

Attaching two screenshots to demonstrate the issue and the difference between Console and QtConsole... ip console ip qtconsole

thorstenkampe commented 9 years ago

...regarding os versus platform: basically nt [win32] doesn't say anything. It just means "Windows."

This is some code I recently wrote to give more meaningful information about the operating system:

if sys.platform == 'win32':
    os_platform = 'Windows {release}'.format(release = platform.release())

elif sys.platform.startswith('linux'):
    os_platform = ' '.join(platform.linux_distribution())

elif sys.platform == 'cygwin':
    os_platform = 'Cygwin {release}'.format(release = platform.release()[:6])

elif sys.platform == 'darwin':
    os_platform = 'OSX {release}'.format(release = platform.mac_ver()[0])

By the way, something like

'Python {version} {arch}'.format(version = platform.python_version(), arch = platform.architecture()[0])

gives a nicer and more concise version for Python, in my opinion.

thorstenkampe commented 9 years ago

I just installed the latest version: OS version looks much better now. The issue regarding the console remains.

jrjohansson commented 9 years ago

OK, thanks for the screenshots. However, I still cannot reproduce this problem in osx or linux. Perhaps it is something windows related. Could you try to explicitly run the IPython.display.display_pretty() on the object returned by version information. I guess the problem might be that there is an error and exception raised when IPython calls the _reprpretty which might prevent this representation from being used:

>>> %load_ext version_information
>>> v = %version_information
>>> import IPython.display
>>> IPython.display.display_pretty(v)
Software versions
Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2]
IPython 2.3.0
OS Linux 3.13.0 36 generic x86_64 with Ubuntu 14.04 trusty
Mon Oct 06 10:33:52 2014 JST
>>> v
Software versions
Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2]
IPython 2.3.0
OS Linux 3.13.0 36 generic x86_64 with Ubuntu 14.04 trusty
Mon Oct 06 10:33:57 2014 JST
jrjohansson commented 9 years ago

Thanks for the suggestions for improved python version presentation. I've adopted a variant of this in 85abf2c15d31ae41f6eae04a0a04baf30bf4b3ac

thorstenkampe commented 9 years ago

Looks very well now. Detailed but not too detailed, in my opinion. Will report back later to the actual bug.

thorstenkampe commented 9 years ago

Please see transcript of IPython console session

Python 3.4.1 64bit on Windows 8
IPython 2.3.0

?         - overview
%quickref - quick reference
object?   - details about `object` (`object??` for extra details)
%magic    - IPython commands

[1]>>> %load_ext version_information
The version_information extension is already loaded. To reload it, use:
  %reload_ext version_information
[2]>>> v = %version_information
[3]>>> import IPython.display
[4]>>> IPython.display.display_pretty(v)
<version_information.VersionInformation object at 0x00000000050BB4E0>
[5]>>> v
[5]    <version_information.VersionInformation object at 0x00000000050BB4E0>
[6]>>>
jrjohansson commented 9 years ago

Hmm, thanks for testing.. Unfortunately this didn't give any new clues. I still think that the _repr_pretty_ in VersionInformation is called but fails for some reason. I'll try to debug it more here, maybe trying to find a Windows computer to test it on. I'll let you know if I find any reason for this problem.