Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anacondaST3: ERROR - Anaconda worker could not start #906

Open
haferburg opened this issue Aug 31, 2021 · 7 comments
Open

anacondaST3: ERROR - Anaconda worker could not start #906

haferburg opened this issue Aug 31, 2021 · 7 comments

Comments

@haferburg
Copy link

haferburg commented Aug 31, 2021

I switched from a normal Python installation on Windows 10 to pyenv.

$ where python
C:\Users\AHaferbu\.pyenv\pyenv-win\shims\python
C:\Users\AHaferbu\.pyenv\pyenv-win\shims\python.bat
C:\Users\AHaferbu\AppData\Local\Microsoft\WindowsApps\python.exe

Now I'm seeing this error in Anaconda 2.20.0 with ST 4107:

anacondaST3: ERROR - Anaconda worker could not start because:

connection to localhost:33174 timed out after 0.2s. tried to connect 7 times during 2.0 seconds

check that there is Python process executing the anaconda jsonserver.py script running in your system. If there is, check that you can connect to your localhost writing the following script in your Sublime Text 3 console:

import socket; socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect(("localhost", 33174))

If anaconda works just fine after you received this error and the command above worked you can make anaconda to do not show you this error anymore setting the 'swallow_startup_errors' to 'true' in your configuration file.

There is no Python process running jsonserver.py.
image

This is frustrating because the error message says "If there is...", but not "if there isn't...".

The error message also says "could not start because...", which suggests to me that it's going to tell me a reason why it didn't start, but then only describes the result, namely that the server is unreachable.

I have swallow_startup_errors set to true, but it still displays the error. There is no popup, though.
image
image

I don't think Anaconda is working. What is odd, though is that running a Python script with the Anaconda Python Builder is working fine.

I found #527, and it's marked as fixed with no comment in the commit message, but I'm still seeing this error message. That is quite frustrating. There's a lot of comments in that issues, and I'm not going to read them all.

It would be great if you would consider changing the error message. At this point I would like to know what Anaconda tries to do, i. e. how does it start the server. Let me know the full command line. Where does it take the Python exe from? What is the output to stderr, stdout when it tries to run?

Also, it would be great if Anaconda would stop printing the same error message every couple seconds. It is my understanding that Anaconda is responsible for starting the server. It didn't, now the server is unreachable. It's cool that Anaconda checks a couple times, but unless it actually tries to restart the server, it should stop trying to connect to it. Unless there's a good reason why that would suddenly work.

To me it looks like - and I'm not familiar with the code at all - error handling is missing when Anaconda tries to start the server. The error message that I'm seeing is complaining about the result from not being able to reach the server. But Anaconda should have told me why it couldn't start the server. The error message above suggests that, but is misleading.

@BrightBulb123
Copy link

+1 on this... I first got this about 2 days ago and got so frustrate I deleted Sublime entirely. Re-installed ST3 today and everything works fine except for Anaconda. Same error as this.

Here are my Windows specifications:

Edition	         Windows 10 Pro
Version	         21H1
Installed on	 ‎10/‎07/‎2021
OS build           19043.1237
Experience	 Windows Feature Experience Pack 120.2212.3530.0

And if you're looking for my logs, here they are:
Python Folder: https://pastebin.com/aj5AD4Fm
Downloads Folder: https://pastebin.com/bmE5YkVf

Although, I fear I may have played a part in this by updating Python to 3.10 and deleting the 3.9 Folder...

By the way, the swallow_startup_errors is only to stop the pop-up I believe.

@rocapp
Copy link

rocapp commented Nov 4, 2021

I got the same error on Windows and was able to fix it, though I'm not sure if it's due to the same bug you're experiencing.

What worked for me:

First, cd to the Anaconda Package directory.

Try running the server:
python anaconda_server\json_server.py

For me, the server failed to start for two reasons--

  1. The lib.path import at the top of jsonserver.py fails because on Windows, there is a built-in module with the same name (lib).

I was able to fix this by editing jsonserver.py-- namely inserted the Anaconda\anaconda_server directory into sys.path-- something like:

sys.path.insert(Path("CORRECT_PATH").resolve())

  1. Windows firewall was blocking the server, which is why there's not a more informative error message than the one you're getting.

I recommend setting an application-specific rule in Windows firewall, as the port can change.

Apologies if anything isn't exactly correct, currently on my phone. I'll check it again when I'm back at my computer. Also, I'll submit a pull request when I have a chance.

@utkonos
Copy link

utkonos commented May 1, 2022

This error is due to the python version that is being used to run jsonserver.py. In macOS, if using homebrew, and you have installed the latest Python, the script will not run. Here is the error when running the script directly in Python 3.10.4:

% python3 jsonserver.py
/Users/demo/Library/Application Support/Sublime Text/Packages/Anaconda/anaconda_server/jsonserver.py:13: DeprecationWarning: The asyncore module is deprecated and will be removed in Python 3.12. The recommended replacement is asyncio
  import asyncore
/Users/demo/Library/Application Support/Sublime Text/Packages/Anaconda/anaconda_server/jsonserver.py:14: DeprecationWarning: The asynchat module is deprecated and will be removed in Python 3.12. The recommended replacement is asyncio
  import asynchat
MyPy is enabled but we could not import it
Usage: jsonserver.py -p <project> -e <extra_paths> ST3_PID

jsonserver.py: error: you have to pass a port number and PID

The solution that I found for this is to specify the interpreter in Anacoda's user settings. Use the following menu path to edit the user settings for Anaconda:

Sublime Text Menu > Preferences > Package Settings > Anaconda > Settings - User

In the settings file, add a python_interpreter field that points to the system python (3.8.9 on macOS). If you have another one installed elsewhere, just point to the absolute path of that location.

{
	"python_interpreter": "/usr/bin/python3",
}

@tvanyo
Copy link

tvanyo commented Jul 23, 2022

I'm using pyenv, so I changed the python_interpreter to the output of which python3, pointing to the .shims directory.

This did not help. I had to go to ~/Library/Application Support/Sublime Text/Packages/Anaconda and change .python-version to match the version number I'm using.

No more error messages, but the server launched the first time I opened a python file and won't start again after closing sublime and starting it again.

Entire thing feels very fragile.

@vinyvince
Copy link

How will i do in Window? Is therea more definitive answer on this point by chance?

@daeh
Copy link

daeh commented Mar 19, 2024

I had to go to ~/Library/Application Support/Sublime Text/Packages/Anaconda and change .python-version to match the version number I'm using.

Wow. Good find. This worked for me too. For me, the path was ~/Library/Application Support/Sublime Text 3/Packages/Anaconda/.python-version. Changed 3.8 -> 3.12 (my system's default conda env python version). Thanks.

@MaxRepin
Copy link

I'm using pyenv, so I changed the python_interpreter to the output of which python3, pointing to the .shims directory.

This did not help. I had to go to ~/Library/Application Support/Sublime Text/Packages/Anaconda and change .python-version to match the version number I'm using.

No more error messages, but the server launched the first time I opened a python file and won't start again after closing sublime and starting it again.

Entire thing feels very fragile.

Very helpful, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants