添加hostname即可
(base) renfangri@IrvingonedeMacBook-Air ~ % sudo vim /etc/hosts
Password:
输入密码
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 IrvingonedeMacBook-Air.local
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/hosts" 14L, 410C
按 i 进行插入
127.0.0.1 IrvingonedeMacBook-Air.local
然后esc 然后 :wq 保存并退出
这是我添加进去的,成功解决问题
注意⚠️:一定要插入到最下面一行,不然还是会报错
不知道主机名的可以这样获得
(base) renfangri@IrvingonedeMacBook-Air ~ % python
Python 3.9.6 | packaged by conda-forge | (default, Jul 11 2021, 03:35:11)
[Clang 11.1.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.gethostname()
'IrvingonedeMacBook-Air.local'
>>>
本文介绍了在Mac上编辑hosts文件以添加hostname的步骤,包括使用sudo vim打开文件,插入hostname,然后使用:wq保存并退出。还分享了如何通过Python获取主机名的方法,并提醒务必在文件末尾添加新行以避免错误。
1117

被折叠的 条评论
为什么被折叠?



