Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work in IPython console #6

Open
thorstenkampe opened this issue Oct 4, 2014 · 10 comments
Open

Doesn't work in IPython console #6

thorstenkampe opened this issue Oct 4, 2014 · 10 comments

Comments

@thorstenkampe
Copy link

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
Copy link
Owner

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?

jrjohansson added a commit that referenced this issue Oct 5, 2014
@thorstenkampe
Copy link
Author

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
Copy link
Author

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

@thorstenkampe
Copy link
Author

...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
Copy link
Author

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

@jrjohansson
Copy link
Owner

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 repr_pretty 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
Copy link
Owner

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

@thorstenkampe
Copy link
Author

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

@thorstenkampe
Copy link
Author

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants