CharacterAI
CharacterAI copied to clipboard
Python not recognizing that lib is installed
Code:
from characterai import PyCAI
client = PyCAI('<my key>')
char = input('Enter CHAR: ')
# Save tgt and history_external_id
# to avoid making a lot of requests
chat = client.chat.get_chat(char)
participants = chat['participants']
# In the list of "participants",
# a character can be at zero or in the first place
if not participants[0]['is_human']:
tgt = participants[0]['user']['username']
else:
tgt = participants[1]['user']['username']
while True:
message = input('You: ')
data = client.chat.send_message(
chat['external_id'], tgt, message
)
name = data['src_char']['participant']['name']
text = data['replies'][0]['text']
print(f"{name}: {text}")
I've used pip install characterai, but when I run the program I get this error:
Exception has occurred: ModuleNotFoundError
No module named 'characterai'
File "C:\Users\Austin\Documents\VScode\CAI\main.py", line 1, in <module>
from characterai import PyCAI
ModuleNotFoundError: No module named 'characterai'
Try to locate the library in your python's site-packages folder.
It is located. Also happening to me
Fixed by using venv
make sure you're using correct python version
try pip --version and python --version in terminal
they should be both the same also make sure your selected interpreter is the same version