Closed bayees closed 6 years ago
Do you have prompt_toolkit installed? Do pip install prompt_toolkit
, to install.
Solved it. Thanks
Just a bit too fast. It didn't fix it.
Traceback (most recent call last):
File "Main.py", line 2, in <module>
from PyInquirer import prompt
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'
It seems its not installed yet. Which environment are you running it from? Anaconda?
conda install -c conda-forge prompt_toolkit
Looking at your error log, it seems you are using a virtual environment. Hope you installed it there.
You should do call scripts/activate
in the venv directory, then 'pip install prompt_toolkit`
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
I updated to newer version of prompt_toolkit and it breaks. So the requirements.txt has been changed to @kensongzhu suggested.
I guess this is resolve now :100: :+1:
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
It doesn't work. I tried it all and I get this error:
ImportError Traceback (most recent call last)
Cell In[8], line 1
----> 1 from PyInquirer import prompt, print_json
2 from langchain.document_loaders import PyPDFLoader
3 import os
File [~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInquirer\__init__.py:6](https://file+.vscode-resource.vscode-cdn.net/d%3A/code/project-palette/langchain/notebooks/~/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0/LocalCache/local-packages/Python38/site-packages/PyInquirer/__init__.py:6)
3 from __future__ import absolute_import, print_function
4 import os
----> 6 from prompt_toolkit.token import Token
7 from prompt_toolkit.styles import style_from_dict
8 from prompt_toolkit.validation import Validator, ValidationError
ImportError: cannot import name 'Token' from 'prompt_toolkit.token' ([C:\Users\flowe\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\prompt_toolkit\token.py](file:///C:/Users/flowe/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0/LocalCache/local-packages/Python38/site-packages/prompt_toolkit/token.py))
still the same issue 4 years later. I am also trying to get it to work in a jupyter notebook with the following versions:
ipython 8.12.0 PyInquirer 1.0.3 prompt-toolkit 3.0.39
File /srv/hemi01-j01/anaconda3/envs/birdshot/lib/python3.9/site-packages/PyInquirer/__init__.py:6
3 from __future__ import absolute_import, print_function
4 import os
----> 6 from prompt_toolkit.token import Token
7 from prompt_toolkit.styles import style_from_dict
8 from prompt_toolkit.validation import Validator, ValidationError
ImportError: cannot import name 'Token' from 'prompt_toolkit.token' (/srv/hemi01-j01/anaconda3/envs/birdshot/lib/python3.9/site-packages/prompt_toolkit/token.py)
With a recent version of prompt_toolkit, PyInquirer fails because of the way it imports the token. With an old version of prompt_toolkit, PyInquirer fails because prompt_toolkit tries to import collections.Mapping which moved to collections.abc years ago....
Basically you cannot use PyInquirer on a modern version of python without a lot of work. Actually, an unknown amount of work, because who knows what other gremlins will bite once this one is fixed.
If you ever needed a canonical example of the mess of Python package management and dependencies, this would be a good one.
EDIT: Someone seems to have done that work and updated in to support modern Pythons: https://github.com/kazhala/InquirerPy . I haven't tried it yet though.
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.