简体   繁体   English

无法在pycharm中启动python控制台

[英]Can't start a python console in pycharm

OS:win7 x64 作业系统:win7 x64

When I click the "python console" tab, I get the following output. 当我单击“ python控制台”选项卡时,得到以下输出。 I had successfully started the python console several months ago, but now I can't. 几个月前,我已经成功启动了python控制台,但是现在不能了。

"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] 由于目标计算机积极拒绝,无法连接。

Finally Solved. 终于解决了。 Add the following to your hosts if you use a local DNS server. 如果您使用本地DNS服务器,请将以下内容添加到主机中。

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

Some people have reported a similar issue here: https://youtrack.jetbrains.com/issue/PY-7070 有人在这里报告了类似的问题: https : //youtrack.jetbrains.com/issue/PY-7070

To quote the answer: 引用答案:

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). 用户可以通过将DNS服务器从本地(由访问点提供)更改为Google DNS服务器(8.8.8.8)来解决此问题。

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). 看起来Mac OS Lion和更高版本之后不首先使用/ etc / hosts文件,而是优先使用DNS服务器,因此localhost可能无法解析(尽管目前尚不清楚为什么它不退回到/ etc / hosts )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM