Sublime Text 3: Anaconda package error connection to localhost timed out
Asked Answered
A

9

13

I am getting a bizarre error message when starting up sublime text 3.

upon startup, I get the error below.

Window Error

Here's some background on my system:

Windows 10

Sublime Text 3 (Anaconda Package installed through Sublime Text package installer)

From CMD:

C:\Users\joshu>where python
C:\cygwin64\bin\python
C:\Users\joshu\Anaconda3\python.exe

C:\Users\joshu>which python
/usr/bin/python

C:\Users\joshu>python --version
Python 3.5.2 :: Anaconda 4.2.0 (64-bit)

From sublime text 3 console:

sys.version
'3.3.6 (default, Sep 22 2016, 23:32:57) [MSC v.1600 64 bit (AMD64)]'

sys.path

['C:\\Users\\joshu\\AppData\\Roaming\\Sublime Text 3\\Installed Packages\\AutoPEP8.sublime-package\\sublimeautopep8lib\\packages_py3', 'C:\\Program Files\\Sublime Text 3', 'C:\\Program Files\\Sublime Text 3/python3.3.zip', 'C:\\Users\\joshu\\AppData\\Roaming\\Sublime Text 3\\Packages', 'C:\\Users\\joshu\\AppData\\Roaming\\SUBLIM~1\\Packages\\pygments\\all', 'C:\\Users\\joshu\\AppData\\Roaming\\SUBLIM~1\\Packages\\coverage\\ST3_WI~2', 'C:\\Users\\joshu\\AppData\\Roaming\\SUBLIM~1\\Packages\\MARKUP~1\\all', 'C:\\Users\\joshu\\AppData\\Roaming\\SUBLIM~1\\Packages\\PYTHON~1\\st3', 'C:\\Users\\joshu\\AppData\\Roaming\\SUBLIM~1\\Packages\\PYTHON~2\\all', 'C:\\Users\\joshu\\AppData\\Roaming\\SUBLIM~1\\Packages\\mdpopups\\st3', 'C:\\Users\\joshu\\AppData\\Roaming\\Sublime Text 3\\Packages\\coverage\\st3_windows_x64']

The first problem is that I don't know how to "check that there is Python process executing the anaconda jsonserver.py script ".

But ultimately I am at a lost on how to fix this issue.

My 'test' to see if anaconda was working was to try importing Numpy (which didn't work.. no module detected).

I did paste the following code into the sublime text 3 console.. didn't look like anything happened:

import socket; socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect(("localhost", 59552))
Atterbury answered 25/1, 2017 at 11:7 Comment(0)
E
12

In the menu:

Preferences > Package Settings > Anaconda > Settings - User

If your user settings file is empty, write:

{
    "swallow_startup_errors": true
}

and save.

If you already have other user settings in this file, just add this one to them

Enunciate answered 5/11, 2018 at 15:33 Comment(2)
While this answer may solve the question, it contains no explanation of how or why it does so.Rheims
It is the Preferences in Sublime Text.Shabbir
A
2

Update: I Found the jsonserver.py file by searching for it in the AppData directory under sublime text..

Sublime Text console:

import sys
print(sys.path)

copy the path to Sublime Text 3 Anaconda folder in the file exploere, then I searched for jsonserver.py

When I tried to open the file, it would close itself. Not sure if that was a good or bad thing.

Ultimately I removed then reinstalled the Anaconda package. That seemed to fix the issue (although I am unsure of the root cause :/ )

Atterbury answered 25/1, 2017 at 12:47 Comment(1)
This is a known issue that they are (as of 4 days from this writing) still working on github.com/DamnWidget/anaconda/issues/527 See also #514.Counterforce
D
2

I had this issue on my Mac. On a terminal I checked if the jsonserver.py was running.

$ ps aux | grep jsonserver
user1         17170   0.0  0.0  4286488    856 s001  S+   10:51am   0:00.00 grep jsonserver.py
user1         14803   0.0  0.4  4358656  74252   ??  S    10:31am   0:06.30 python -B /path/to/jsonserver.py -p cxda 51380 -e /path/to/folders/,/path/to/other/folder/ 7973
user1         14787   0.0  0.2  4312684  26444   ??  S    10:31am   0:00.53 python -B /path/to/jsonserver.py -p cxda 51357 -e /path/to/folders/,/path/to/other/folder/ 7973

The results showed I had two jsonservers running using the same port. So I disabled anaconda in Sublime using command+shift+p and searching for Package Control: Disable Package. Simply type disa and it should come up straight away.

After disabling the package, I killed the two processes.

$ kill 14803
$ kill 14787
$ ps aux | grep jsonserver
user1         17220   0.0  0.0  4277272    840 s001  S+   10:52am   0:00.00 grep jsonserver.py

Then I enabled the package via package control in sublime using command+shift+p. Enabling the package will start a new jsonserver.py. This solved the issue for me.

Dyun answered 1/8, 2019 at 10:8 Comment(0)
B
2

The following works for me : I add python.exe executable path to the Path environment variable.

Bobine answered 28/7, 2021 at 21:46 Comment(0)
B
1

1. Note

I think, that this problem may arise by another reasons, than described in my answer. And you will need in another solutions.

But my solution works for me personally.


2. Answer

Don't set "jsonserver_debug": true in settings, if you don't run jsonserver.py manually.

If "jsonserver_debug": true, you need python -B anaconda_server/jsonserver.py -p test 9999 DEBUG in Anaconda folder, that Anaconda works correct.


3. Demonstration

3.1. Unexpected behavior

If "jsonserver_debug": true:

True

If I open .py file:

    Anaconda doesn't work (not autoformat file in example).

3.2. Expected behavior

If "jsonserver_debug": false:

False

Anaconda successful autoformat example file.


4. Environment

My environment in time, when I wrote this answer:

  • Windows 10 Enterprise LTSB 64-bit EN,
  • Sublime Text Build 3143 portable,
  • Python 3.6.4, installed globally,
  • Anaconda 2.1.25.
Bascule answered 17/1, 2018 at 17:43 Comment(0)
D
1

I had the same problem on OS X and tried almost every solution you can find on the web. the problem seems to be related to a delay in json server response time so that when it exceeds 2 Seconds you get the error.

there are two possible workarounds:

first method is by increasing the time out:

change the line 33 in /anaconda_lib/workers/local_worker.py

from

timeout = get_socket_timeout(0.2)

to

timeout = get_socket_timeout(1)

this should help you with the error by giving a little more time to perform server checks before throwing an error.

the second method is by changing permissions on anaconda log file to make sure it is owned by your user, as stated by the original contributer:

Anaconda behaves slowly and jsonserver crashes

If you are in POSIX systems (Linux or OS X) take a look at the owner of the anaconda's jsonserver log files, they must be owned by your user or the jsonserver would be unable to start up. Log files can be found in:

GNU/Linux: ~/.local/share/anaconda/logs

OS X: ~/Library/Logs/anaconda

Windows: %APPDATA%\Anaconda\Logs

This is how I was able to resolve the issue:

1- delete ~/Library/Logs/anaconda directory

2- run sublime text and open some .py files until anaconda recreates the directory

3- give read/write permissions to that folder and its sub-directories for every user on your computer (administrator,everyone,etc...)

there is a good chance you'll have to repeat the steps above every now and then. that's what I do volunteerly before anaconda makes me to do so!

UPDATE

I've found that the problem can be caused by VPN connection as well, so that everytime I connect and disconnect this error shows up.

Doughnut answered 31/1, 2020 at 1:59 Comment(0)
T
1

In SublimeText 3 for Windows 10 I received this same error.

Under Preferences -> Package Settings -> Anaconda -> Settings - Default

I had to change the setting value of python_interpreter from python to the path to my anaconda installation's python.exe.

In my case on Windows 10 it looked like the following:

    "python_interpreter": "C:/ProgramData/Anaconda3/python.exe",

Your path may be different depending on where you installed Anaconda.

After doing this it seems like all the linting features, etc are working OK. No messing with JSON servers or ignoring error messages required.

Think answered 20/12, 2021 at 22:5 Comment(0)
F
0

Just enter this inside sublime 3 console: view -> show console

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

50390 is a diferent number.

Fjeld answered 31/8, 2019 at 1:8 Comment(0)
F
0
  1. Check if the jsonserver.py is running? $ ps aux | grep jsonserver

  2. If not, try to change the default Anaconda Python interpreter from python to python3. In the preference > Package Settings > Anaconda > "Settings - Default", and search "python_interpreter", then change to "python3".

Restart sublime text!

Forme answered 7/12, 2022 at 1:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.