-
Notifications
You must be signed in to change notification settings - Fork 51
Wrong python interpreter by default #55
Comments
Yes, it is, you have to choose right interpreter for your project once, the logic for auto select python interpreter is quite complex. |
Is there a reason why you don't just choose the first one on my $PATH? (And can I suggest you update the README, because I can't see any other way of interpreting "By default we use the one that's on your path"?) |
It's logic from vscode-python, just fixed the doc. |
I can't read TS/JS, so I don't understand the logic, but I would imagine it makes some sense for a GUI app, where environment is weird. But for vim, which is (usually) a CLI program, there is no better guess that the first But if it's the intended behavior feel free to close this. (One more thing about the README " |
There could be multiple python in $PAH, like python and python3, we still not sure which one should be used. vim can be use in both gui and tui environment, so I tend to keep this logic. |
I also agree that using the interpreter as in That being said, is there any programmatic way (e.g. vimscript) to configure python path? |
My vote is for two new mutually exclusive settings If But if |
|
Ah. OK then. My vote is for |
(and renaming either |
|
I have |
My current workaround: call coc#config('python', {
\ 'jediEnabled': v:false,
\ 'pythonPath': split(execute('!which python'), '\n')[-1]
\ }) But I've found it to present several issues. On a virtualenv, I miss builtins like |
@chemzqm maybe coc-python should ignore, or at least have a setting to ignore |
I wanted to summarize things for those new to coc and coc-python and stumbled here by google search (like me). Please correct me if this is wrong. @chemzqm recently wrote a memo system to store the selected python interpreter. That means, you may be able to simply set the python interpreter for a file/project and it will be remembered. To set up initially:
Then select the correct interpreter for your project. As @chemzqm indicated here, a more direct (but non-programmatic) way to deal with this issue is to add pythonPath to your config on a per-project basis:
|
Another workaround would be to place a dummy Python interpreter.
|
If you set |
@chemzqm I am finding the current behaviour hard to reason about:
In addition something about the default behaviour is selecting my global python over the currently active virtualenv (perhaps because global is Py 3.8, but virtualenv is only 3.7) -- this behaviour is massively confusing to me as a linux user. Would you accept a PR to reorder/change the detection to favour active virtual env more? |
@ashb there must be something wrong with your setup because there's actually a memo system, and at least for me it works, it has been even mentioned in this thread already. The only issue everyone is hitting is no automatic env detection on first use. |
More than willing to believe something is wrong, but I don't even know where to start. The log files are... verbose. When should this memo system come in to play? So for you are you saying that once you run setInterpreter it saves it, even if you close and open vim, and if you have mutliple vims in different folders? Also this is for vim -- the equivalent of Vimscript |
It comes into play from start, when it sets some python executable by default, which may not be the one you want, then you set the one you want, and coc.nvim updates it on |
Thanks @oblitum In trying to reproduce this I deleted my memos file and now can't reproduce it. (I have questions about the amount of duplication in the memos file, but that's a separate issue) Back to the original question at hand: I (and I guess most people here) would prefer the default option is |
I believe |
And actually the same thing happens for a previous snippet I've shared. |
Too many possible ways of creating venvs in python I guess. (I'm using virtualenvwrapper with my venvs in ~/.virtualenvs/) |
My workaround with Add the following to
|
Hmm, I'm also not sure this is the desired behaviour. coc-python now picks a conda environment as default interpreter, because it's a higher version than my system python. I would prefer to only use conda interpreters if they're actually activated. |
This is a complex matter to pin down, hence personally I'm just ok with setting it once per workspace. |
If you use pyenv and pyenv_virtualenv you can also just use the following in init.vim/.vimrc:
|
Reference: neoclide/coc-python#55 (comment)
According to the README
I take this to mean the default should match the output of which python. But it doesn't.
e.g. on my machine
and then in vim after
:CocCommand python.setInterpreter
I get:The value I'm expecting to be the default is the 9th on the list and the order of these items seeems to be random.
How do I fix this? Or is this the intended behavior?
The text was updated successfully, but these errors were encountered: