Library is not compatible with `prompt_toolkit>=2.0.0`wait for update to released ipython to fix.
Closed this issue · 9 comments
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.
(FYI: Looks like prompt_toolkit
version 2.0.3 breaks ipython so probably no rush to "fix" this.)
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: ipython-dev@python.org
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.
#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.
I confirm I get the same error as @danilobellini described.
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
.
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.
I'm not against this approach, If we go with it:
- We should open an issue to
Remove support for prompt_toolkit v1 when ubuntu updates
(or similar); - Skip the coverage of
v1
related code in #1223 using# pragma: no cover
(https://coverage.readthedocs.io/en/coverage-4.2/excluding.html)
Closed by #1223.
Thanks @danilobellini 👍