I've created a simple script to begin building a python prompt with prompt_toolkit
but am getting the following error:
ImportError: cannot import name 'PromptSession' from partially initialized module 'prompt_toolkit' (most likely due to a circular import) (/Users/coreyfarmer/Coding/Testing/prompt_toolkit.py)
I'm running python3.8.7
in a virtualenv, but seem to be running into the issue outside of the virtualenv and with varying versions of python as well. I have also tried uninstalling and reinstalling varying versions of prompt_toolkit
with the same results.
The script is simple and is based off samples/examples on the prompt_toolkit docs:
from prompt_toolkit import PromptSession
def start ( ) :
session = PromptSession()
text1 = session.prompt("Give me some input: ")
print( "You said: %s" % text1 )
if __name__ == "__main__" :
start ()
Any thoughts on how to resolve would be very welcome.
UPDATE
After changing the filename from prompt_toolkit.py
(which was conflicting with the package name) to my_prompt_toolkit.py
I get the following error:
~/Coding via v3.8.7 (env)
❯ python3 Testing/my_prompt_toolkit.py
Traceback (most recent call last):
File "Testing/my_prompt_toolkit.py", line 1, in <module>
from prompt_toolkit import PromptSession
ImportError: cannot import name 'PromptSession' from 'prompt_toolkit'
(/Users/coreyfarmer/Coding/valet.com/env/lib/python3.8/site-packages/prompt_toolkit/__init__.py)
Which is strange because I know the package exists and is in the right place:
~/Coding via v3.8.7 (env)
❯ python3 -m pip show prompt_toolkit
Name: prompt-toolkit
Version: 1.0.18
Summary: Library for building powerful interactive command lines in Python
Home-page: https://github.com/jonathanslenders/python-prompt-toolkit
Author: Jonathan Slenders
Author-email: UNKNOWN
License: UNKNOWN
Location: /Users/coreyfarmer/Coding/valet.com/env/lib/python3.8/site-packages
Requires: six, wcwidth
Required-by: