![]() |
#1 |
Zealot
![]() Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
|
Using an interactive Python interpreter
After reading and searching, I find that
from calibre import ipython ipython(locals()) code will not be useful, because now calibre do not conclude ipython. So I think the https://manual.calibre-ebook.com/develop.html#id14 need to change. And now what can I do to Using an interactive Python interpreter |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,242
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
In the absence of ipython it will run a simple python REPL.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Zealot
![]() Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
|
I run this in windows, it just raise error, with:
Python function terminated unexpectedly cannot import name ipython(Error Code: 1) in directly open calibre. And in cmd calibredb Hello world Python function terminated unexpectedly cannot import name ipython (Error Code: 1) Traceback (most recent call last): File "site.py", line 114, in main File "site.py", line 87, in run_entry_point File "D:\workplace\program\open-sourse\calibre-src\src\calibre\__init__.py", line 7, in <module> from calibre import ipython ImportError: cannot import name ipython My code is from __future__ import unicode_literals, print_function ''' E-book management software''' __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal <kovid@kovidgoyal.net>' __docformat__ = 'restructuredtext en' print("Hello world") from calibre import ipython ipython(locals()) And I am working with the 4.12.0 with the source code of 4.12.0 |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,242
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Works for me with
calibre-debug -c "from calibre import ipython; ipython()" have you edited the source code of calibre/__init__.py?? |
![]() |
![]() |
![]() |
#5 | |
Zealot
![]() Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
|
Quote:
I add print ("Hello, world!") near the top of __init__.py. It works. Then I continue to read and simply add code after print ("Hello, world!") , which cause error. Then I find that calibre-debug -c "from calibre import ipython; ipython()" works with the unchange __init__.py. Then I add from calibre import ipython ipython(locals()) to the end of __init__.py It works. After some checking, I find I should use those codes after defining of ipython function. |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Zealot
![]() Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
|
After further testing, I find ipython somehow not working? is usefull.
And if someone like me want to use the ipython, here is the way: open src\calibre\utils\ipython.py, add sys.path.extend([the path you got]) neer the top of this file, but after import os, re, sys , then we can use from calibre import ipython ipython(locals()) to open ipython again. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Python 2 to Python 3, Polyglot & Plugins | DaltonST | Calibre | 18 | 04-24-2019 12:10 AM |
Glulxe Interactive Fiction interpreter compiled for Kindle PW (via KTerm) | pete330 | Kindle Developer's Corner | 16 | 12-13-2013 11:46 AM |
Git Glulx Interactive Fiction interpreter compiled for Kindle PW (via KTerm) | pete330 | Kindle Developer's Corner | 1 | 09-24-2013 01:06 PM |
TADS Interactive Fiction interpreter compiled for Kindle PW (via KTerm) | pete330 | Kindle Developer's Corner | 14 | 08-26-2013 11:22 PM |
PRS-600 Interactive Interpreter | luma | Sony Reader Dev Corner | 1 | 07-24-2010 12:19 PM |