DamnWidget / anaconda

Anaconda turns your Sublime Text 3 in a full featured Python development IDE including autocompletion, code linting, IDE features, autopep8 formating, McCabe complexity checker Vagrant and Docker support for Sublime Text 3 using Jedi, PyFlakes, pep8, MyPy, PyLint, pep257 and McCabe that will never freeze your Sublime Text 3
http://damnwidget.github.io/anaconda/
GNU General Public License v3.0
2.21k stars 260 forks source link

anacondaST3: ERROR - Anaconda worker could not start #906

Open haferburg opened 3 years ago

haferburg commented 3 years ago

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 commented 2 years ago

+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 commented 2 years ago

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())

2) 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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

daeh commented 6 months ago

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 commented 4 months ago

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!

cornopaez commented 1 week ago

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.

This worked for me in late 2024.