CharacterAI icon indicating copy to clipboard operation
CharacterAI copied to clipboard

Python not recognizing that lib is installed

Open teccdev opened this issue 1 year ago • 4 comments

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'

teccdev avatar Jan 07 '24 17:01 teccdev

Try to locate the library in your python's site-packages folder.

Karvp avatar Jan 08 '24 09:01 Karvp

It is located. Also happening to me

BobbyESP avatar Jan 10 '24 15:01 BobbyESP

Fixed by using venv

BobbyESP avatar Jan 10 '24 16:01 BobbyESP

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

MrCytrusLY avatar Jan 13 '24 20:01 MrCytrusLY