khoj-ai / khoj

Your AI second brain. Self-hostable. Get answers from the web or your docs. Build custom agents, schedule automations, do deep research. Turn any online or local LLM into your personal, autonomous AI (e.g gpt, claude, gemini, llama, qwen, mistral).
https://khoj.dev
GNU Affero General Public License v3.0
16.67k stars 812 forks source link

Can't uninstall khoj #462

Closed BMiber closed 1 year ago

BMiber commented 1 year ago

Downloaded khoj in powershell and I checked, runs in both command terminal and powershell. I try to uninstall with pip uninstall khoj-assistant but it says WARNING: Skipping khoj-assistant as it is not installed.

sabaimran commented 1 year ago

@BMiber , that sounds rather strange! I tried to reproduce it on my end, but was able to uninstall.

(.venv) si@redwood test-uninstall % pip uninstall khoj-assistant
Found existing installation: khoj-assistant 0.11.1
Uninstalling khoj-assistant-0.11.1:
  Would remove:
    /Users/si/projects/test-uninstall/.venv/bin/khoj
    /Users/si/projects/test-uninstall/.venv/lib/python3.11/site-packages/khoj/*
    /Users/si/projects/test-uninstall/.venv/lib/python3.11/site-packages/khoj_assistant-0.11.1.dist-info/*
Proceed (Y/n)? Y
  Successfully uninstalled khoj-assistant-0.11.1
(.venv) si@redwood test-uninstall %

Could you provide more information about your development environment -- are you using a virtual environment? Are you running the uninstall command from the same environment?

sabaimran commented 1 year ago

Closing this as it's been stale. Feel free to reopen if you're able to share more details.

STORMFIRE007 commented 3 weeks ago

i am facing the same issue: i am self hosting khoj and installed it using pip on windows

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Windows\system32> pip uninstall khoj
WARNING: Skipping khoj as it is not installed.
PS C:\Windows\system32>

edit:

my bad, i was following the instructions at https://docs.khoj.dev/get-started/setup#uninstall-server to uninstall khoj, but from reading the messages above, looks like the correct uninstallation method is pip uninstall khoj-assistant

sabaimran commented 3 weeks ago

Yup! All good. It has to be pip uninstall khoj-assistant.

STORMFIRE007 commented 3 weeks ago

Sorry but now even the pip uninstall khoj-assistant isn't working anymore, it worked for the first time, but now when i tried uninstalling khoj again using the same command, it's not working

PS C:\Windows\system32> pip uninstall khoj
WARNING: Skipping khoj as it is not installed.
PS C:\Windows\system32> pip uninstall khoj-assistant
WARNING: Skipping khoj-assistant as it is not installed.
PS C:\Windows\system32>

khoj is clearly installed as i can run it using khoj --anonymous-mode :

PS C:\Windows\system32> pip uninstall khoj-assistant
WARNING: Skipping khoj-assistant as it is not installed.
PS C:\Windows\system32> khoj --anonymous-mode
[19:54:44.723520] WARNING  khoj.routers.email: RESEND_API_KEY not set - email sending disabled               email.py:26
[19:54:44.988461] INFO     khoj: 🚒 Initializing Khoj v1.28.3                                                main.py:130
[19:54:44.998454] INFO     khoj: 📦 Initializing DB:                                                         main.py:131
                           Operations to perform:
                             Apply all migrations: admin, auth, contenttypes, database, django_apscheduler,
                           sessions
                           Running migrations:
                             No migrations to apply.
[19:54:45.044459] INFO     khoj: 🌘 Starting Khoj                                                            main.py:144
[19:54:45.066453] INFO     khoj: 🔒 Schedule Leader elected                                                  main.py:168
[19:54:45.121280] INFO     khoj: Started Background Scheduler                                                main.py:178
[19:54:46.208568] INFO     khoj.configure: 🚨 Khoj is not configured.                                   configure.py:216
                           Initializing it with a default config.
[19:55:00.676428] INFO     khoj.configure: 📡 Telemetry enabled                                         configure.py:259
[19:55:00.703427] INFO     khoj: 🚒 Initializing Khoj v1.28.3                                                main.py:130
[19:55:00.709428] INFO     khoj: 📦 Initializing DB:                                                         main.py:131
                           Operations to perform:
                             Apply all migrations: admin, auth, contenttypes, database, django_apscheduler,
                           sessions
                           Running migrations:
                             No migrations to apply.
[19:55:00.729429] INFO     khoj: 🌘 Starting Khoj                                                            main.py:144
[19:55:00.741425] INFO     khoj: 🔒 Schedule Leader is already running                                       main.py:165
[19:55:00.750430] INFO     khoj: Started Background Scheduler                                                main.py:178
[19:55:01.438209] INFO     khoj.configure: 🚨 Khoj is not configured.                                   configure.py:216
                           Initializing it with a default config.
[19:55:13.203775] INFO     khoj.configure: 📡 Telemetry enabled                                         configure.py:259
[19:55:13.210772] INFO     khoj: 🌖 Khoj is ready to use                                                     main.py:214
[19:55:13.394524] INFO     uvicorn.error: Started server process [19208]                                    server.py:82
[19:55:13.401475] INFO     uvicorn.error: Waiting for application startup.                                      on.py:48
[19:55:13.413470] INFO     uvicorn.error: Application startup complete.                                         on.py:62
[19:55:13.420475] INFO     uvicorn.error: Uvicorn running on http://127.0.0.1:42110 (Press CTRL+C to quit) server.py:214
sabaimran commented 3 weeks ago

Huh, that's weird. Why does it seem to be creating two threads? A lonely of the log lines are duplicated.

Where did you install? You didn't use a virtual environment?

Couple things to try investigating here:

# Check where pip is installing packages
python -m site

# Check specific package details
pip show khoj-assistant

This should help you collect some orientation on where the package is installed, get proof that it's actually there. It can help us debug further.

These are some other uninstallation methods you can try:

# uninstall with the user flag
pip uninstall khoj-assistant

# uninstall using full module path
python -m pip uninstall khoj-assistant
STORMFIRE007 commented 3 weeks ago

no i didn't use a virtual environment, was that required? i apologize for the mistake

running the commands you suggested returns these messages:

PS C:\Windows\system32> python -m site
sys.path = [
    'C:\\Windows\\system32',
    'C:\\Users\\Storm Fire\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
    'C:\\Users\\Storm Fire\\AppData\\Local\\Programs\\Python\\Python310\\DLLs',
    'C:\\Users\\Storm Fire\\AppData\\Local\\Programs\\Python\\Python310\\lib',
    'C:\\Users\\Storm Fire\\AppData\\Local\\Programs\\Python\\Python310',
    'C:\\Users\\Storm Fire\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages',
]
USER_BASE: 'C:\\Users\\Storm Fire\\AppData\\Roaming\\Python' (exists)
USER_SITE: 'C:\\Users\\Storm Fire\\AppData\\Roaming\\Python\\Python310\\site-packages' (doesn't exist)
ENABLE_USER_SITE: True
PS C:\Windows\system32> pip show khoj-assistant
WARNING: Package(s) not found: khoj-assistant
PS C:\Windows\system32> python -m pip uninstall khoj-assistant
WARNING: Skipping khoj-assistant as it is not installed.
PS C:\Windows\system32> pip uninstall khoj-assistant
WARNING: Skipping khoj-assistant as it is not installed.
PS C:\Windows\system32>
sabaimran commented 3 weeks ago

It's generally better to use virtual environments, because it isolates your packages! Highly recommend. See venv.

Ah sorry, I messed up one of my commands. Can you also try this one? pip uninstall --user khoj.

Also, I just remembered we transferred our package to the name khoj, so the commands don't need to use khoj-assistant. Can you try again?

pip show khoj
pip uninstall khoj
python -m pip uninstall khoj

Try pip list and see if either khoj-assistant or khoj are there.

What was the command you used to install the package?

STORMFIRE007 commented 3 weeks ago

Ah sorry, I messed up one of my commands. Can you also try this one? pip uninstall --user khoj.

hmm.. it does nothing?:

PS C:\Windows\system32> pip uninstall --user khoj

Usage:
  pip uninstall [options] <package> ...
  pip uninstall [options] -r <requirements file> ...

no such option: --user
PS C:\Windows\system32>

Also, I just remembered we transferred our package to the name khoj, so the commands don't need to use khoj-assistant. Can you try again?

pip show khoj
pip uninstall khoj
python -m pip uninstall khoj

here are the results:

PS C:\Windows\system32> pip show khoj
WARNING: Package(s) not found: khoj
PS C:\Windows\system32> pip uninstall khoj
WARNING: Skipping khoj as it is not installed.
PS C:\Windows\system32> python -m pip uninstall khoj
WARNING: Skipping khoj as it is not installed.

Try pip list and see if either khoj-assistant or khoj are there.

i don't see it there, weird, since i am able to run it using khoj --anonymous-mode :

PS C:\Windows\system32> pip list
Package                      Version
---------------------------- -----------
aiohttp                      3.9.5
aiosignal                    1.3.1
annotated-types              0.6.0
anthropic                    0.26.1
anyio                        3.7.1
APScheduler                  3.10.4
asgiref                      3.8.1
async-timeout                4.0.3
attrs                        24.2.0
Authlib                      1.2.1
beautifulsoup4               4.12.3
Brotli                       1.1.0
cachetools                   5.5.0
certifi                      2024.8.30
cffi                         1.17.1
charset-normalizer           3.3.2
click                        8.1.7
colorama                     0.4.6
coloredlogs                  15.0.1
cron-descriptor              1.4.3
cryptography                 43.0.3
dataclasses-json             0.6.7
dateparser                   1.2.0
defusedxml                   0.7.1
diskcache                    5.6.3
distro                       1.9.0
Django                       5.0.9
django-apscheduler           0.6.2
django-phonenumber-field     7.3.0
dnspython                    2.7.0
docx2txt                     0.8
einops                       0.8.0
email_validator              2.2.0
exceptiongroup               1.2.0
fastapi                      0.110.0
filelock                     3.16.1
flatbuffers                  24.3.25
frozenlist                   1.5.0
fsspec                       2024.10.0
google-ai-generativelanguage 0.6.10
google-api-core              2.22.0
google-api-python-client     2.151.0
google-auth                  2.36.0
google-auth-httplib2         0.2.0
google-generativeai          0.8.3
googleapis-common-protos     1.65.0
greenlet                     3.1.1
grpcio                       1.67.1
grpcio-status                1.67.1
h11                          0.14.0
httpcore                     0.18.0
httplib2                     0.22.0
httpx                        0.25.0
huggingface-hub              0.26.2
humanfriendly                10.0
idna                         3.6
itsdangerous                 2.1.2
Jinja2                       3.1.4
jiter                        0.7.0
joblib                       1.4.2
jsonpatch                    1.33
jsonpointer                  3.0.0
langchain                    0.2.5
langchain-community          0.2.5
langchain-core               0.2.43
langchain-text-splitters     0.2.4
langsmith                    0.1.141
llama_cpp_python             0.2.88
llvmlite                     0.43.0
lxml                         4.9.3
magika                       0.5.1
markdown-it-py               3.0.0
markdownify                  0.11.6
MarkupSafe                   3.0.2
marshmallow                  3.23.1
mdurl                        0.1.2
more-itertools               10.5.0
mpmath                       1.3.0
multidict                    6.1.0
mutagen                      1.47.0
mypy-extensions              1.0.0
networkx                     3.4.2
numba                        0.60.0
numpy                        1.26.4
onnxruntime                  1.20.0
openai                       1.54.3
openai-whisper               20240930
opencv-python                4.10.0.84
orjson                       3.10.11
packaging                    24.2
pgvector                     0.2.4
phonenumbers                 8.13.27
piexif                       1.1.3
Pillow                       10.0.1
pip                          24.3.1
propcache                    0.2.0
proto-plus                   1.25.0
protobuf                     5.28.3
psutil                       6.1.0
psycopg2-binary              2.9.9
pyasn1                       0.6.1
pyasn1_modules               0.4.1
pyclipper                    1.3.0.post6
pycparser                    2.22
pycryptodomex                3.20.0
pydantic                     2.6.3
pydantic_core                2.16.3
Pygments                     2.18.0
PyMuPDF                      1.24.11
pyparsing                    3.2.0
pyreadline3                  3.5.4
python-dateutil              2.9.0.post0
python-dotenv                1.0.1
python-multipart             0.0.17
pytz                         2024.2
PyYAML                       6.0.2
rapidocr-onnxruntime         1.3.24
regex                        2024.11.6
requests                     2.32.3
requests-toolbelt            1.0.0
rich                         13.9.4
rsa                          4.9
safetensors                  0.4.5
schedule                     1.1.0
scikit-learn                 1.5.2
scipy                        1.14.1
sentence-transformers        3.0.1
setuptools                   65.5.0
shapely                      2.0.6
six                          1.16.0
sniffio                      1.3.1
soupsieve                    2.6
SQLAlchemy                   2.0.36
sqlparse                     0.5.1
starlette                    0.36.3
sympy                        1.13.3
tabulate                     0.9.0
tenacity                     8.3.0
threadpoolctl                3.5.0
tiktoken                     0.8.0
tokenizers                   0.20.3
torch                        2.2.2
tqdm                         4.67.0
transformers                 4.46.2
typing_extensions            4.12.2
typing-inspect               0.9.0
tzdata                       2023.3
tzlocal                      5.2
uritemplate                  4.1.1
urllib3                      2.2.2
uvicorn                      0.30.6
websockets                   12.0
yarl                         1.17.1
yt-dlp                       2024.8.6

What was the command you used to install the package?

i use the one available on the https://docs.khoj.dev/get-started/setup/#setup-khoj page:

# 1. To use NVIDIA (CUDA) GPU
$env:CMAKE_ARGS = "-DGGML_CUDA=on"
# 2. Install Khoj
py -m pip install khoj

although the model doesn't run on GPU, it runs on CPU and loads into the RAM instead of VRAM, and downloads the GGUF models, unless i am misunderstanding here, do i have to manually enter a hugging face GPTQ or AWQ model for it to run in on my RTX 2060? (instead of a GGUF, which iirc is more suitable to run on a CPU (based on my knowledge of 1-2 years ago when messing with oobabooga textgen webui))

sabaimran commented 3 weeks ago

Weird. Okay we are going to try a few more things. First, let's see where that package is loading from.

where khoj

Next, try running this same command in reverse for uninstall. Just a shot in the dark.

py -m pip uninstall khoj

For running the model,

although the model doesn't run on GPU, it runs on CPU and loads into the RAM instead of VRAM, and downloads the GGUF models, unless i am misunderstanding here, do i have to manually enter a hugging face GPTQ or AWQ model for it to run in on my RTX 2060? (instead of a GGUF, which iirc is more suitable to run on a CPU (based on my knowledge of 1-2 years ago when messing with oobabooga textgen webui))

To be totally honest, I'm not sure. Because we don't have a GPU-enabled windows for testing, it's hard to verify some of these behaviors. You should be able to try out the other model types and run it. You just have to set the type to Offline and drop the name of the other model on huggingface in a new chatmodel option. Can you make a separate discussion for that issue?

STORMFIRE007 commented 3 weeks ago

Weird. Okay we are going to try a few more things. First, let's see where that package is loading from.

where khoj

weird, that result in nothing?...:

PS C:\Windows\system32> where khoj
PS C:\Windows\system32>

For running the model,

To be totally honest, I'm not sure. Because we don't have a GPU-enabled windows for testing, it's hard to verify some of these behaviors. You should be able to try out the other model types and run it. You just have to set the type to Offline and drop the name of the other model on huggingface in a new chatmodel option. Can you make a separate discussion for that issue?

sure, just to confirm if i am not misunderstanding, you want me to create a seperate post in "issues" or "discussions"?

Next, try running this same command in reverse for uninstall. Just a shot in the dark.

py -m pip uninstall khoj

well that finally worked, thanks a lot for your help 👍:

output of py -m pip uninstall khoj.txt

btw just in case if it helps, here's some additional diagnostic information: i am running all of these commands on windows powershell and ran it as administrator also, there might have been complications when i tried installing and uninstalling khoj multiple times, perhaps i might have ran the install khoj command again when it was already installed and that broke some stuff?

sabaimran commented 3 weeks ago

sure, just to confirm if i am not misunderstanding, you want me to create a seperate post in "issues" or "discussions"?

Discussions is a good better idea! Usually, that's better if there's a bit of an open-ended question with uncertain resolution, not specifically a bug. Here's a link -- https://github.com/khoj-ai/khoj/discussions/

Glad to hear we could finally uninstall it! Whew. Thanks for your patience.

I don't think running the commands multiple times should have been a problem. I do recommend using WSL, as most things will generally "just work" that way, since you'll have a unix environment. Appreciate the additional context.

sabaimran commented 2 weeks ago

Hey, just giving a quick update in this thread since I was able to reproduce the issue and found a fix for two threads starting. For what it's worth, the second thread wasn't starting a server, so it wouldn't have affected any of the performance. Here's the commit with the fix. Should be in the next release.

STORMFIRE007 commented 2 weeks ago

i see, thanks a lot for information and fixing the issue 👍