Comments (11)
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
from pyinquirer.
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
from pyinquirer.
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.
from pyinquirer.
Do you have prompt_toolkit installed? Do pip install prompt_toolkit
, to install.
from pyinquirer.
Solved it. Thanks
from pyinquirer.
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'
from pyinquirer.
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`
from pyinquirer.
I updated to newer version of prompt_toolkit and it breaks. So the requirements.txt has been changed to @kensongzhu suggested.
from pyinquirer.
I guess this is resolve now 💯 👍
from pyinquirer.
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))
from pyinquirer.
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)
from pyinquirer.
Related Issues (20)
- AssertionError when using example
- MAC Terminal Support HOT 1
- Multiline Messages
- Crash on clic HOT 2
- ImportError: cannot import name 'Mapping' from 'collections' (C:\Python310\lib\collections\__init__.py) HOT 7
- Tests are failing on a clean fork HOT 1
- PageSize is not working
- My HOT 1
- Applying style to a prompt throws an error HOT 3
- List input with prompt multiple lines long moves down a line every time cursor moves
- Request: Upgrade code for compatibility with prompt_toolkit 3.0.29
- Typo in 'input.py' HOT 2
- Separator colour isn't applied for 'list' types.
- Add support for Python version 3.10 HOT 4
- prompt.prompt should be prompt(questions, style=custom_style_2)
- Request: add option for "select all"/"unselect all" to checkbox question type HOT 1
- ImportError: cannot import name 'Mapping' from 'collections' error when importing PyInquirer | HAS SOLUTION HOT 7
- prompt_toolkit version for pyinquirer not compatible with ipython HOT 2
- Accessing the variable input
- ModuleNotFoundError: PyInquirer Not Detected in Virtual Environment HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyinquirer.