Axelrod-Python/Axelrod

Axelrod pip install in Colab fails due to prompt_toolkit

Closed this issue ยท 3 comments

It appears a version mismatch for prompt_toolkit causes problems for pip installing Axelrod in Colab.

!pip install -q axelrod

results in

ERROR: jupyter-console 5.2.0 has requirement prompt-toolkit<2.0.0,>=1.0.0, but you'll have prompt-toolkit 3.0.8 which is incompatible.
ERROR: ipython 5.5.0 has requirement prompt-toolkit<2.0.0,>=1.0.4, but you'll have prompt-toolkit 3.0.8 which is incompatible.

Please see a reproduction of this error in this notebook

Colab uses an old version of IPython. Here's the workaround for now.

First note we have another issue with the PyYAML version (needs to be >= 5.1 because we use FullLoader). So first run

!pip install --ignore-installed PyYAML

The latest dev version of Axelrod can be installed in Colab with this command

!pip install git+https://github.com/Axelrod-Python/Axelrod.git@dev

After running these commands, import axelrod works. However it puts Colab into an unhappy state where the kernel has to be "factory reset" to reload properly.

To fix, we need to do two things:

  • For prompt-toolkit we can make it an optional import / requirement or find another workaround
  • For PyYAML we just need to update requirements.txt or change FullLoader to Loader or SafeLoader. See here and here.
  • For prompt-toolkit we can make it an optional import / requirement or find another workaround

If I'm correct we only use prompt-toolkit for the Human player, making it optional with a clear message could be a way forward?

I'll open a PR for the pyyaml bump now PR to bump pyyaml: #1380

If I'm correct we only use prompt-toolkit for the Human player, making it optional with a clear message could be a way forward?

I think that's a good fix for now.