Open sleighsoft opened 6 years ago
When you get the Project or interpreter switch detected
is because the python_interpreter
in your configuration (per project, per user or global) is not the same than the one that is currently being used by the anaconda's JsonServer so anaconda kills that JsonServer and starts a new one with the new interpreter.
To be able to see which interpreters are in play in your system for a given view (buffer) at any time just open the Sublime Text 3 console and write:
from Anaconda.anaconda_lib.helpers import get_settings
from Anaconda.anaconda_lib.workers.market import Market
print('Configured Interpreter: {}'.format(get_settings(view, 'python_interpreter')))
print('In use Interpreter for view {}: {}'.format(view.file_name(), Market.get(Market, window.id()).interpreter.raw_interpreter))
This is a working setting
>>> from Anaconda.anaconda_lib.helpers import get_settings
>>> from Anaconda.anaconda_lib.workers.market import Market
>>> print('Configured Interpreter: {}'.format(get_settings(view, 'python_interpreter')))
Configured Interpreter: C:\Development\miniconda\envs\test\python.exe
>>> print('In use Interpreter for view {}: {}'.format(view.file_name(), Market.get(Market, window.id()).interpreter.raw_interpreter))
In use Interpreter for view C:\Development\Github\mp2017-gan\...\pipelines.py: C:\Development\miniconda\envs\test\python.exe
>>> from Anaconda.anaconda_lib.helpers import get_settings
>>> from Anaconda.anaconda_lib.workers.market import Market
>>> print('Configured Interpreter: {}'.format(get_settings(view, 'python_interpreter')))
Configured Interpreter: C:\Development\miniconda\envs\test\python.exe
>>> print('In use Interpreter for view {}: {}'.format(view.file_name(), Market.get(Market, window.id()).interpreter.raw_interpreter))
In use Interpreter for view C:\Development\Github\..\pipelines.py: python
This is what I get once I run into the interpreter switch problem. After that anaconda does not work anymore.
The .raw_interpreter
property of the Worker.interpreter
object is set on initialization only and it gets initialized if there is a change in the python_interpreter
configuration option, as it only gets set after reading python_interpreter
and with the value of the python_interpreter
, this is probably some corner case with windows (and probably the anaconda python distribution) as I don't use Windows at all and could not test the plugin on Windows as deep as in other platforms.
To get rid of the annoyance just set the auto_project_switch
property in your config to false
I had this exact problem because I entered ~/Code/p3-gitlab-svn/bin/python
in my project settings. Anaconda would see that as different to /home/heerij/Code/p3-gitlab-svn/bin/python
and keep killing and restarting the interpreter. But... it only happened if I used "go to definition" while in a site-packages
installed module in a virtualenv.
Basically, I had my own script open, I would do ctrl-alt-g
on dulwich.client.send_pack()
. This would open and jump to the relevant file. Then when I tried to to ctrl-alt-g
on write_pack_contents
I'd start seeing the message anacondaST3: Project or interpreter switch detected...
>>> print('Configured Interpreter: {}'.format(get_settings(view, 'python_interpreter')))
Configured Interpreter: /home/heerij/Code/p3-gitlab-svn/bin/python
>>> print('In use Interpreter for view {}: {}'.format(view.file_name(), Market.get(Market, window.id()).interpreter.raw_interpreter))
In use Interpreter for view /home/heerij/Code/p3-gitlab-svn/lib/python3.6/site-packages/dulwich/client.py: ~/Code/p3-gitlab-svn/bin/python
The problem stopped when I used the full path instead of ~/...
. It also stopped if the site-packages
module source was already open!
This is a bit muddled because I'm just getting the notes down before I need to leave the computer. If I have time later, I'll try to create a test procedure for you.
Off the top of my head, with no knowledge of the source whatsoever, I'd suggest there's a comparison between a path that's been run through os.path.abspath()
and a path that has been pulled straight from settings...?
(Ubuntu 17.04, ST3 3143, latest Anaconda in PC)
It could definitely be an issue with go to definition and site packages. These are things I did aswell @DamnWidget I have set auto project switch to false in my project .anaconda file but it does not seem to help.
Do you have any new log?
The anaconda_jsonserver.log
does not show any new insights.
In my case noted multiple anaconda servers keep running when anaconda stops responding to GUI. So to reset it, closing ST3 and manually killing jsonservers is required. Not sure when exactly that happens though (extensively using "quick project switch" and having multiple projects open in separate ST3 windows).
upd.: It seems that issue is caused by using tilde (~) instead of full homedir path in project settings (same as @detly noted).
Expected Behaviour
Auto completion and show documentation work
Actual Behaviour
Auto completion and all other anaconda feature work and stop working after a couple of minutes.
Steps to Reproduce
I don't know. It might be related to "Project switch detected" even though I just have a single project opened.
ST3, Anaconda and OS versions
Win 10 ST3 Build 3143 Anaconda version from today
ST3 Console Logs
Anaconda's JsonServer Logs