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

create_prompt_application missing from 2.x #647

Closed
ibeex opened this issue Jun 21, 2018 · 8 comments
Closed

create_prompt_application missing from 2.x #647

ibeex opened this issue Jun 21, 2018 · 8 comments

Comments

@ibeex
Copy link
Contributor

ibeex commented Jun 21, 2018

>>> prompt_toolkit.__version__
'2.0.3'
>>> from prompt_toolkit.shortcuts import create_prompt_application
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'create_prompt_application'

ipython and lots off other apps don't work any more.

@jonathanslenders
Copy link
Member

Hi @ibeex,

IPython does indeed not yet run on prompt_toolkit 2.0. They're working hard on that.
See this issue: ipython/ipython#11177

If you have some time available, it would be great if you could help them testing the latest IPython version from GitHub.

@techtonik
Copy link
Contributor

IPython merged, but is there a porting guide for all other apps?

@jonathanslenders
Copy link
Member

There is: https://python-prompt-toolkit.readthedocs.io/en/2.0/pages/upgrading.html
It's probably not complete, but let me know if you think something important is missing.

@ProbonoBonobo
Copy link

ProbonoBonobo commented Jul 29, 2018

For anyone needing a temporary workaround, I can confirm that reverting to v.1.x mostly resolves the errors that prevent ipython, ptpython, etc. from initializing:


$ git clone -b 1.0  --single-branch https://github.com/jonathanslenders/python-prompt-toolkit.git
$ cd python-prompt-toolkit 
$ python3 setup.py install 
$ cd ..
$ export python_prompt_toolkit_install_dir=$(pip3 show prompt_toolkit | echo $(grep -w "Location:")  | awk '{ print substr( $0, 11 ) }')/prompt-toolkit
$ pip3 uninstall prompt_toolkit
$ cp -Rf python-prompt-toolkit $python_prompt_toolkit_install_dir

You might get the following error when launching ptpython if you're using the default config.py template...

~/dev/git/clones/python-prompt-toolkit$ ptpython
Traceback (most recent call last):
  File "/home/kevin/.local/lib/python3.6/site-packages/ptpython/repl.py", line 244, in run_config
    six.exec_(code, namespace, namespace)
  File "/home/kevin/.ptpython/config.py", line 8, in <module>
    from prompt_toolkit.key_binding.key_processor import KeyPress
ModuleNotFoundError: No module named 'prompt_toolkit.key_binding.key_processor'

...but it's not fatal, and can be safely ignored, or you could delete the offending lines. A quick glance at the code suggests KeyPress is only used to map the 'jj' key sequence to 'Esc' in vim mode.

@ProbonoBonobo
Copy link

ProbonoBonobo commented Jul 30, 2018

@jonathanslenders Weird... the kludge above worked for me yesterday, but it's throwing the following stacktrace today:

$ ptpython
Traceback (most recent call last):
  File "/home/kevin/.local/bin/ptpython", line 7, in <module>
    from ptpython.entry_points.run_ptpython import run
  File "/home/kevin/.local/lib/python3.6/site-packages/ptpython/entry_points/run_ptpython.py", line 25, in <module>
    from ptpython.repl import embed, enable_deprecation_warnings, run_config
  File "/home/kevin/.local/lib/python3.6/site-packages/ptpython/repl.py", line 15, in <module>
    from prompt_toolkit.application import AbortAction
  File "/home/kevin/.local/lib/python3.6/site-packages/prompt_toolkit/__init__.py", line 16, in <module>
    from .interface import CommandLineInterface
  File "/home/kevin/.local/lib/python3.6/site-packages/prompt_toolkit/interface.py", line 19, in <module>
    from .application import Application, AbortAction
  File "/home/kevin/.local/lib/python3.6/site-packages/prompt_toolkit/application/__init__.py", line 2, in <module>
    from .application import Application
  File "/home/kevin/.local/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 3, in <module>
    from prompt_toolkit.buffer import Buffer
  File "/home/kevin/.local/lib/python3.6/site-packages/prompt_toolkit/buffer.py", line 9, in <module>
    from .completion import Completer, Completion, CompleteEvent
  File "/home/kevin/.local/lib/python3.6/site-packages/prompt_toolkit/completion/__init__.py", line 2, in <module>
    from .base import Completion, Completer, ThreadedCompleter, DummyCompleter, DynamicCompleter, CompleteEvent, merge_completers, get_common_complete_suffix
  File "/home/kevin/.local/lib/python3.6/site-packages/prompt_toolkit/completion/base.py", line 4, in <module>
    from prompt_toolkit.eventloop import generator_to_async_generator, AsyncGeneratorItem
ImportError: cannot import name 'generator_to_async_generator'

Can you suggest a better workaround? I'm utterly hooked on your excellent ptpython REPL and I'm afraid I don't understand the nature of these breaking changes well enough to patch them.

Edit: my bad, I assumed incorrectly that running "python3 setup.py install" would replace the existing prompt-toolkit installation -- it doesn't. I'm guessing this worked yesterday only because I was already in the cloned downstream branch. I'll edit the instructions.

@gpotter2
Copy link
Contributor

gpotter2 commented May 2, 2019

I think this issue could be closed :)

@jonathanslenders
Copy link
Member

Ok, closing it. Feel free to open again if needed.

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

5 participants