Skip to content

Library is not compatible with prompt_toolkit>=2.0.0wait for update to released ipython to fix. #1183

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

Closed
drvinceknight opened this issue Jul 6, 2018 · 9 comments

Comments

@drvinceknight
Copy link
Member

With prompt_toolkit version 2.0.3 we get an import error:

======================================================================
ERROR: axelrod (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: axelrod
Traceback (most recent call last):
  File "/home/vince/anaconda3/lib/python3.6/unittest/loader.py", line 153, in loadTestsFromName
    module = __import__(module_name)
  File "/home/vince/src/Axelrod/axelrod/__init__.py", line 17, in <module>
    from .strategies import *
  File "/home/vince/src/Axelrod/axelrod/strategies/__init__.py", line 2, in <module>
    from ._strategies import *
  File "/home/vince/src/Axelrod/axelrod/strategies/_strategies.py", line 47, in <module>
    from .human import Human
  File "/home/vince/src/Axelrod/axelrod/strategies/human.py", line 3, in <module>
    from prompt_toolkit.token import Token
ImportError: cannot import name 'Token'

Note that in #1182 I've pinned the version of prompt_toolkit in requirements.txt. Once this is fixed we should unpin.

@drvinceknight
Copy link
Member Author

(FYI: Looks like prompt_toolkit version 2.0.3 breaks ipython so probably no rush to "fix" this.)

@drvinceknight drvinceknight changed the title Change to prompt-toolkit Library is not compatible with prompt_toolkit>1.0.15 Jul 6, 2018
@drvinceknight drvinceknight changed the title Library is not compatible with prompt_toolkit>1.0.15 Library is not compatible with prompt_toolkit>=2.0.0 Jul 6, 2018
@drvinceknight drvinceknight changed the title Library is not compatible with prompt_toolkit>=2.0.0 Library is not compatible with prompt_toolkit>=2.0.0wait for update to released ipython to fix. Oct 31, 2018
@drvinceknight drvinceknight reopened this Oct 31, 2018
@drvinceknight
Copy link
Member Author

Following a discussion with @danilobellini on #1223 it looks like the latest conda release of jupyter/ipython now uses prompt_toolkit>=2.0.0.

$  conda create -q -n tmp-env-test-ipython python=3
$ source activate tmp-env-test-ipython
$ conda install jupyter
$ pip show ipython
Name: ipython
Version: 7.1.1
Summary: IPython: Productive Interactive Computing
Home-page: https://ipython.org
Author: The IPython Development Team
Author-email: [email protected]
License: BSD
Location: /home/vince/anaconda3/envs/tmp-env-test-ipython/lib/python3.7/site-packages
Requires: prompt-toolkit, setuptools, traitlets, jedi, pickleshare, backcall, pexpect, decorator, pygments
Required-by: jupyter-console, ipywidgets, ipykernel

Could be worth reapplying #1212 but we should make sure it works and doesn't break common tools.

@danilobellini
Copy link
Member

#1212 didn't work here with prompt_toolkit v2.

>>> import axelrod as axl
>>> players = [axl.Human(name="Fulano"), axl.TitForTat()]
>>> match = axl.Match(players, turns=8)
>>> match.play()

Starting new match
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/axelrod/match.py", line 145, in play
    self.players[0].play(self.players[1], self.noise)
  File "/usr/lib/python3.7/site-packages/axelrod/player.py", line 220, in play
    s1, s2 = self.strategy(opponent), opponent.strategy(self)
  File "/usr/lib/python3.7/site-packages/axelrod/strategies/human.py", line 148, in strategy
    action = self._get_human_input()
  File "/usr/lib/python3.7/site-packages/axelrod/strategies/human.py", line 128, in _get_human_input
    style=toolbar_style,
  File "/usr/lib/python3.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 840, in prompt
    return session.prompt(*a, **kw)
TypeError: prompt() got an unexpected keyword argument 'get_bottom_toolbar_tokens'

That's fixed on #1223.

@drvinceknight
Copy link
Member Author

I confirm I get the same error as @danilobellini described.

@drvinceknight
Copy link
Member Author

I've had to remove a couple of jupyter kernels and reinstall but otherwise everything is working (famous last words) on my system with ipython/jupyter now using prompt_toolkit>=2.0.0.

@danilobellini
Copy link
Member

Ubuntu is still using prompt_toolkit v1.0.15 and IPython<=5.5.0. I don't encourage people to perform sudo pip3 install axelrod, but these people won't be able to use the latest version of the package (and probably won't notice that for some time) if it stops supporting prompt_toolkit v1. I suggest to keep the support for both prompt_toolkit versions at least while the Ubuntu long-term release keeps the v1.

@drvinceknight
Copy link
Member Author

I'm not against this approach, If we go with it:

@drvinceknight
Copy link
Member Author

Closed by #1223.

@drvinceknight
Copy link
Member Author

Thanks @danilobellini 👍

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