Connection Refused Error:[WinError 10061]

【问题】

Vscode左边栏选项,运行和调试,运行Python Django,程序报错:

sock.connect((host, port))
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

【解决】

无线网host地址设置问题

第一步:

在命令端窗口输入以下命令获取IP地址

>python

>>>import socket

>>>host = socket.gethostname()

>>>print(host)

hostname      #主机名

>>>host = socket.gethostbyname("hostname")   #hostname为上一步获取的主机名

>>>print(host)   #输出IP地址

第二步:

修改默认的的IP地址

打开Django项目的manage.py文件,修改main方法

if __name__ == "__main__":

    Runserver.default_addr = "host"

第三步:

修改ALLOWER_HOSTS

打开Django项目的settings.py文件

ALLOWER_HOSTS = ["host"]

再次运行程序

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Jupyter error: could not install packages due to an EnvironmentError: [WinError] is commonly encountered when trying to install packages using Jupyter Notebook on a Windows operating system. This error indicates that there is an issue with the environment or the system's permissions. One possible cause of this error is that the package being installed requires administrative privileges to be installed correctly. In this case, you can try running the Jupyter Notebook as an administrator by right-clicking on the Jupyter shortcut and selecting the "Run as administrator" option. This may resolve the permissions issue and allow the packages to be installed successfully. Another possible cause is that there might be a conflict between different Python versions or dependencies. In such cases, it is recommended to create a new virtual environment using a tool like Anaconda, which helps manage different Python environments and their dependencies. This can help resolve any conflicts and ensure a clean installation of packages without encountering environment errors. It is also possible that the error is related to the local network configuration or proxy settings. In this case, it might be helpful to check the network connection, firewall settings, and proxy configurations. Disabling the firewall temporarily or configuring the proxy settings correctly can sometimes resolve the installation issue. In some cases, this error can also occur due to insufficient storage space. Make sure that there is enough disk space available for installing the packages. If the issue persists, it is recommended to search for specific error messages or codes encountered during the installation process. This can provide more specific insights into the root cause of the problem and guide towards a more targeted solution. Overall, this error usually occurs due to permission, dependency, network, or storage issues. By following the above suggestions and troubleshooting steps, you should be able to resolve the environment error and successfully install packages in Jupyter Notebook.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值