Python lsp not resolving packages in venv #1367

Closed
opened 2026-02-16 17:30:38 -05:00 by yindo · 16 comments
Owner

Originally created by @jscheel on GitHub (Aug 18, 2025).

Originally assigned to: @rekram1-node on GitHub.

For the last two releases the python lsp is not properly picking up packages in my venv.

Functionally, this manifests in errors like Error [15:6] Import "dotenv" could not be resolved showing up in certain tool calls. This was not a problem on earlier releases.

Just grabbed 0.5.6, as I saw that it had a fix for a bug around this (https://github.com/sst/opencode/pull/1994), but the issue persists.

Happy to provide any debugging necessary!

Originally created by @jscheel on GitHub (Aug 18, 2025). Originally assigned to: @rekram1-node on GitHub. For the last two releases the python lsp is not properly picking up packages in my venv. Functionally, this manifests in errors like `Error [15:6] Import "dotenv" could not be resolved` showing up in certain tool calls. This was not a problem on earlier releases. Just grabbed 0.5.6, as I saw that it had a fix for a bug around this (https://github.com/sst/opencode/pull/1994), but the issue persists. Happy to provide any debugging necessary!
yindo closed this issue 2026-02-16 17:30:38 -05:00
Author
Owner

@rekram1-node commented on GitHub (Aug 18, 2025):

hmm I am gonna look into this and try to replicate

@rekram1-node commented on GitHub (Aug 18, 2025): hmm I am gonna look into this and try to replicate
Author
Owner

@rekram1-node commented on GitHub (Aug 18, 2025):

I am assuming this is default behavior right? this isn't due to a custom lsp config

are you using uv?

@rekram1-node commented on GitHub (Aug 18, 2025): I am assuming this is default behavior right? this isn't due to a custom lsp config are you using `uv`?
Author
Owner

@jscheel commented on GitHub (Aug 18, 2025):

afaik I don't have any special lsp config. I am definitely using uv though.

@jscheel commented on GitHub (Aug 18, 2025): afaik I don't have any special lsp config. I am definitely using uv though.
Author
Owner

@rekram1-node commented on GitHub (Aug 18, 2025):

cool, I will try to replicate

Edit: Managed to replicate

@rekram1-node commented on GitHub (Aug 18, 2025): cool, I will try to replicate Edit: Managed to replicate
Author
Owner

@rekram1-node commented on GitHub (Aug 18, 2025):

Ik the issue! @jscheel I will make a more elegant solution but for the time being if you set:

title="pyrightconfig.json"

{
  "venvPath": ".",
  "venv": ".venv"
}

at the root of your project it should be fixed

@rekram1-node commented on GitHub (Aug 18, 2025): Ik the issue! @jscheel I will make a more elegant solution but for the time being if you set: title="pyrightconfig.json" ```json { "venvPath": ".", "venv": ".venv" } ``` at the root of your project it should be fixed
Author
Owner

@rekram1-node commented on GitHub (Aug 18, 2025):

I will get a patch out for this later tonight most likely, will be in one of the next releases

@rekram1-node commented on GitHub (Aug 18, 2025): I will get a patch out for this later tonight most likely, will be in one of the next releases
Author
Owner

@jscheel commented on GitHub (Aug 18, 2025):

@rekram1-node just stepped away from my computer, but I'll give it a try shortly. Thank you!

@jscheel commented on GitHub (Aug 18, 2025): @rekram1-node just stepped away from my computer, but I'll give it a try shortly. Thank you!
Author
Owner

@rekram1-node commented on GitHub (Aug 18, 2025):

if it doesnt just lmk the patch needs to be sophisticated anyway cause not everyone has it in .venv

@rekram1-node commented on GitHub (Aug 18, 2025): if it doesnt just lmk the patch needs to be sophisticated anyway cause not everyone has it in .venv
Author
Owner

@jscheel commented on GitHub (Aug 18, 2025):

@rekram1-node seems to fix it for me 👍 Thanks!

@jscheel commented on GitHub (Aug 18, 2025): @rekram1-node seems to fix it for me 👍 Thanks!
Author
Owner

@rekram1-node commented on GitHub (Aug 31, 2025):

should be fixed in next release, I got busy and got to this much later than I wanted to

@rekram1-node commented on GitHub (Aug 31, 2025): should be fixed in next release, I got busy and got to this much later than I wanted to
Author
Owner

@drorata commented on GitHub (Oct 18, 2025):

I am a new user of opencode, and I get the following error/warning:

Error [2:8] Import "typer" could not be resolved

and co. I am using version 0.15.7 and the virtual environment is .venv/. What am I missing? It seems like opencode fails to find/see the virtual environment.

@drorata commented on GitHub (Oct 18, 2025): I am a new user of opencode, and I get the following error/warning: ``` Error [2:8] Import "typer" could not be resolved ``` and co. I am using version 0.15.7 and the virtual environment is `.venv/`. What am I missing? It seems like `opencode` fails to find/see the virtual environment.
Author
Owner

@rekram1-node commented on GitHub (Oct 18, 2025):

@drorata does that config thing I mentioned above fix it?

If not you can disable the python lsp for now put the following in your opencode.json:

{
“pyright”: {
disabled: true

}}

pardon my horrible json im typing on phone haha so just make that valid json and itll work^^

@rekram1-node commented on GitHub (Oct 18, 2025): @drorata does that config thing I mentioned above fix it? If not you can disable the python lsp for now put the following in your opencode.json: { “pyright”: { disabled: true }} pardon my horrible json im typing on phone haha so just make that valid json and itll work^^
Author
Owner

@drorata commented on GitHub (Oct 19, 2025):

I tried to place either of the following in opencode.json:

{
    "venvPath": ".",
    "venv": ".venv"
}

and

{
    "pyright": {
        "disabled": true
    }
}

In both cases I got the following error:

Error: Config file at /Users/foo/bar/opencode.json is invalid
↳ Unrecognized keys: "venvPath", "venv"
@drorata commented on GitHub (Oct 19, 2025): I tried to place either of the following in `opencode.json`: ```json { "venvPath": ".", "venv": ".venv" } ``` and ```json { "pyright": { "disabled": true } } ``` In both cases I got the following error: ``` Error: Config file at /Users/foo/bar/opencode.json is invalid ↳ Unrecognized keys: "venvPath", "venv" ```
Author
Owner

@rekram1-node commented on GitHub (Oct 19, 2025):

@drorata in opencode.json:

{
  "lsp": {
    “pyright”: {
       "disabled": true
    }
  }
}

The other reply was about pyrightconfig.json:

https://github.com/sst/opencode/issues/2050#issuecomment-3198621399

@rekram1-node commented on GitHub (Oct 19, 2025): @drorata in opencode.json: ``` { "lsp": { “pyright”: { "disabled": true } } } ``` The other reply was about pyrightconfig.json: https://github.com/sst/opencode/issues/2050#issuecomment-3198621399
Author
Owner

@drorata commented on GitHub (Oct 20, 2025):

I'm sorry for the noise -

I didn't change anything, but now it seems to be OK even without the config. I'm still getting a little confused here though... It seems like opencode fails to identify the right environment and I get the following error:

Shell Check the help output to confirm the --debug flag is added

$ cd /Users/foo/bar && python main.py --help
Traceback (most recent call last):
  File "/Users/drorata/dev/humaintain/vimeo_manage/main.py", line 3, in <module>
    import typer
ModuleNotFoundError: No module named 'typer'

It should have tried something like:

source .venv/bin/activate && python main.py --help

because I'm using venv.

@drorata commented on GitHub (Oct 20, 2025): I'm sorry for the noise - I didn't change anything, but now it seems to be OK even without the config. I'm still getting a little confused here though... It seems like `opencode` fails to identify the right environment and I get the following error: ``` Shell Check the help output to confirm the --debug flag is added $ cd /Users/foo/bar && python main.py --help Traceback (most recent call last): File "/Users/drorata/dev/humaintain/vimeo_manage/main.py", line 3, in <module> import typer ModuleNotFoundError: No module named 'typer' ``` It should have tried something like: ``` source .venv/bin/activate && python main.py --help ``` because I'm using `venv`.
Author
Owner

@rekram1-node commented on GitHub (Oct 20, 2025):

hmm ill look into that

@rekram1-node commented on GitHub (Oct 20, 2025): hmm ill look into that
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1367