question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name 'Token'

See original GitHub issue

Getting following error: Traceback (most recent call last): File "Main.py", line 2, in <module> from PyInquirer import prompt, print_json File "C:\Users\CBAY\OneDrive - Netcompany\Python Projects\TimeRegistration\venv\lib\site-packages\PyInquirer\__init__.py", line 6, in <module> from prompt_toolkit.token import Token ImportError: cannot import name 'Token'

Running on Windows 10 Enterprise both in Powershell and Cmder. Same error.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

41reactions
kensongzhucommented, Jul 3, 2018

I got the same issue. A walkaround is to downgrade the prompt_toolkit and it worked for me. pip install ‘prompt_toolkit==1.0.14’

Maybe better change the version of prompt_toolkit in requirements.txt: prompt_toolkit==1.0.14

Otherwise will always use latest version of prompt_toolkit FYI: There is breaking update in prompt_toolkit 2.0

10reactions
MehdiSaffarcommented, May 12, 2020

pip install ‘prompt_toolkit==1.0.14’

Unfortunately this now makes ipython 7.12.0 not work.

ERROR: ipython 7.12.0 has requirement prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0, but you'll have prompt-toolkit 1.0.14 which is incompatible.

when trying to use ipython it gives the following error:

Traceback (most recent call last):
  File "/home/xxx/anaconda3/envs/ox/bin/ipython", line 7, in <module>
    from IPython import start_ipython
  File "/home/xxx/anaconda3/envs/ox/lib/python3.8/site-packages/IPython/__init__.py", line 56, in <module>
    from .terminal.embed import embed
  File "/home/xxx/anaconda3/envs/ox/lib/python3.8/site-packages/IPython/terminal/embed.py", line 16, in <module>
    from IPython.terminal.interactiveshell import TerminalInteractiveShell
  File "/home/xxx/anaconda3/envs/ox/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 21, in <module>
    from prompt_toolkit.formatted_text import PygmentsTokens
ModuleNotFoundError: No module named 'prompt_toolkit.formatted_text'   

after pip install prompt_toolkit ipython now works again but pyinquirer fails

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python cannot import 'Token' from 'token' - Stack Overflow
I'm trying to make a lexer in python but when I try to import a class from file token.
Read more >
Issue 46324: 'import traceback' Causes a Crash - Python tracker
I was developing a programming language using Python, and I had a 'token.py' file. After changing the name of the file, the issue...
Read more >
eth-brownie/community - Gitter
ImportError : cannot import name 'Token' from 'brownie' (/home/ajit-soman/.local/pipx/venvs/eth-brownie/lib/python3.8/site-packages/brownie/init.py).
Read more >
from brownie import Token, accounts
Exception has occurred : ImportError cannot import name 'Token' from ' ... but they assume you have a Token contract defined. brownie bake ......
Read more >
cannot import name '_sanitize_token' from django - Reddit
The culprit seems to be this commit that renamed the function the ImportError is complaining about. Try downgrading django.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found