无法在 pycharm 中启动 python 控制台 [英] Can't start a python console in pycharm

查看:92
本文介绍了无法在 pycharm 中启动 python 控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

操作系统:win7 x64

OS:win7 x64

当我单击python 控制台"选项卡时,我得到以下输出.几个月前我已经成功启动了 python 控制台,但现在我不能.

When I click the "python console" tab, I get the following output. I had successfully started the python console several months ago, but now I can't.

"C:\Program Files\Python36\python.exe" "C:\Program Files\JetBrains\PyCharm 2017.2.3\helpers\pydev\pydevconsole.py" 52527 52528
PyDev console: starting.
import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend(['D:\\2017编程\\python', 'D:/2017编程/python'])
Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2017.2.3\helpers\pydev\_pydev_bundle\pydev_console_utils.py", line 257, in add_exec
    self.finish_exec(more)
  File "C:\Program Files\JetBrains\PyCharm 2017.2.3\helpers\pydev\_pydev_bundle\pydev_console_utils.py", line 434, in finish_exec
    return server.NotifyFinished(more)
  File "C:\Program Files\Python36\lib\xmlrpc\client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "C:\Program Files\Python36\lib\xmlrpc\client.py", line 1452, in __request
    verbose=self.__verbose
  File "C:\Program Files\Python36\lib\xmlrpc\client.py", line 1154, in request
    return self.single_request(host, handler, request_body, verbose)
  File "C:\Program Files\Python36\lib\xmlrpc\client.py", line 1166, in single_request
    http_conn = self.send_request(host, handler, request_body, verbose)
  File "C:\Program Files\Python36\lib\xmlrpc\client.py", line 1279, in send_request
    self.send_content(connection, request_body)
  File "C:\Program Files\Python36\lib\xmlrpc\client.py", line 1309, in send_content
    connection.endheaders(request_body)
  File "C:\Program Files\Python36\lib\http\client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Program Files\Python36\lib\http\client.py", line 1026, in _send_output
    self.send(msg)
  File "C:\Program Files\Python36\lib\http\client.py", line 964, in send
    self.connect()
  File "C:\Program Files\Python36\lib\http\client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "C:\Program Files\Python36\lib\socket.py", line 722, in create_connection
    raise err
  File "C:\Program Files\Python36\lib\socket.py", line 713, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

终于解决了.如果您使用本地 DNS 服务器,请将以下内容添加到您的主机中.

Finally Solved. Add the following to your hosts if you use a local DNS server.

::1 localhost
127.0.0.1 localhost
255.255.255.255 broadcasthost
fe80::1%lo0 localhost

推荐答案

有些人在这里报告了类似的问题:https://youtrack.jetbrains.com/issue/PY-7070

Some people have reported a similar issue here: https://youtrack.jetbrains.com/issue/PY-7070

引用答案:

用户可以通过更改 DNS 服务器来解决问题本地一个(由接入点提供)到 Google DNS 服务器(8.8.8.8).

User was able to fix the problem by changing the DNS server from the local one (provided by the access point) to Google DNS server (8.8.8.8).

它看起来像 Mac OS Lion 和更高版本不首先使用/etc/hosts 文件,优先考虑 DNS 服务器,因此 localhost 可能没有解决(虽然,目前还不清楚为什么它不回落到/etc/hosts).

It looks like Mac OS Lion and later doesn't use /etc/hosts file first, giving priority to DNS servers, hence it's possible that localhost may not resolve (though, it's unclear why it doesn't fall back to /etc/hosts).

这篇关于无法在 pycharm 中启动 python 控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆