Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 03-16-2020, 04:01 AM   #1
The_book
Zealot
The_book began at the beginning.
 
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
The_book is offline   Reply With Quote
Old 03-16-2020, 04:28 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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.
kovidgoyal is offline   Reply With Quote
Advert
Old 03-16-2020, 06:37 AM   #3
The_book
Zealot
The_book began at the beginning.
 
Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
Quote:
Originally Posted by kovidgoyal View Post
In the absence of ipython it will run a simple python REPL.
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
The_book is offline   Reply With Quote
Old 03-16-2020, 07:46 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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??
kovidgoyal is offline   Reply With Quote
Old 03-16-2020, 08:34 AM   #5
The_book
Zealot
The_book began at the beginning.
 
Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
Quote:
Originally Posted by kovidgoyal View Post
Works for me with

calibre-debug -c "from calibre import ipython; ipython()"


have you edited the source code of calibre/__init__.py??
Yes, and I find why.
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.
The_book is offline   Reply With Quote
Advert
Old 03-17-2020, 08:53 AM   #6
The_book
Zealot
The_book began at the beginning.
 
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.
The_book is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 12:01 AM.


MobileRead.com is a privately owned, operated and funded community.