kramcat / CharacterAI

Unofficial Python API for character.ai
https://docs.kram.cat
MIT License
379 stars 52 forks source link

Python not recognizing that lib is installed #80

Open BeepyDev opened 5 months ago

BeepyDev commented 5 months ago

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'
Karvp commented 5 months ago

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

BobbyESP commented 5 months ago

It is located. Also happening to me

BobbyESP commented 5 months ago

Fixed by using venv

MrCytrusLY commented 5 months ago

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