python文件的host可以写主机名吗 python修改hosts_pycharm安装xlrd失败


pycharm安装激活过程中,提示 this license **** has been cancelled 。这个问题并不是你的激活码不对,而是需要修改系统的hosts文件,下面详细讲解下如何修改hosts文件。

一.找到hosts文件

首先找到hosts文件所在目录:(以windoes为例,其他平台操作类似)


Windows:C:WindowsSystem32driversetchosts
Linux:/etc/hosts
Mac:/etc/hosts


python文件的host可以写主机名吗 python修改hosts_python_02


hosts文件并没有后缀,直接是没有办法修改的。因为记事本只能打开txt,推荐下载任意一款代码编辑器,推荐使用 NotePad++,使用比较简单,并且支持多种语言。

如果担心文件修改出错,可以先复制一份作为备份,然后用鼠标右键选择 edit with NotePad++ 或者打开 notepad++之后,直接把hosts文件拖到notepad++里面也一样,这样我们便能看到hosts文件的具体内容:


# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host
 
# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost


二.修改hosts文件

如果想pycharm能正常使用,我们需要在hosts文件的内容的末尾在添加一行代码:0.0.0.0 http://account.jetbrains.com,注意代码中间的空格,一个字符都不能错,如果担心写错,请直接复制下面的代码,然后粘贴到文件中,修改之后记得保存。


0.0.0.0 account.jetbrains.com


三.检查hosts文件是否修改成功

很多小伙伴说修改了,但是还是报错 this license **** has been cancelled !在步骤完成之后,请使用notepad++重新打开检查hosts文件,是否最后一行代码添加成功,如果没有this 0.0.0.0 http://account.jetbrains.com,只能说明你没有修改成功。

有时候可能是C盘权限问题,你可以直接复制一份hosts文件到桌面,修改好之后,再拷贝回去,直接覆盖原始的hosts文件即可,这种方法最简单(推荐)

不管是第一次安装还是以后再次出现这种问题,你只需要记住:this license **** has been cancelled 这个错误 99.99%都跟你的hosts文件有关系。