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

前端 未结 6 1992
孤城傲影
孤城傲影 2021-02-08 16:17

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

upon startup, I get the error below.

Here\'s some background on my system:

<
相关标签:
6条回答
  • 2021-02-08 16:31

    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 :/ )

    0 讨论(0)
  • 2021-02-08 16:34

    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.

    0 讨论(0)
  • 2021-02-08 16:36

    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.

    0 讨论(0)
  • 2021-02-08 16:39

    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.

    0 讨论(0)
  • 2021-02-08 16:40

    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.
    0 讨论(0)
  • 2021-02-08 16:48

    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

    0 讨论(0)
提交回复
热议问题