簡體   English   中英

當我使用 pip 安裝時無法在 wsl 中建立新連接

[英]Failed to establish a new connection in wsl when i use pip install

我想在 Windows 11 上的 ubuntu 子系統 (WSL) 的虛擬環境中安裝 flask-sqlalchemy,使用以下命令:

 pip install flask-sqlalchemy

但是我在控制台 window 中收到錯誤。

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7ff5c27dff10>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/flask-sqlalchemy/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7ff5c2620280>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/flask-sqlalchemy/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7ff5c2620520>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/flask-sqlalchemy/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7ff5c26206d0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/flask-sqlalchemy/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7ff5c2620880>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/flask-sqlalchemy/
ERROR: Could not find a version that satisfies the requirement flask-sqlalchemy (from versions: none)
ERROR: No matching distribution found for flask-sqlalchemy  

我認為它與我的 Ubuntu 子系統中的網絡連接有關。 我嘗試在 Standalone Linux 系統上運行,它似乎可以正常工作。 我該如何解決這個問題?

我最終解決了我的問題。 我發布以下步驟來解決這個問題。 我檢查了我的防火牆設置。 這不是問題。 我不使用代理所以我跳過了代理問題。

我從控制台 window 檢查了 ping

ping google.com

它顯示

ping: google.com: Temporary failure in name resolution

我找到了解決辦法。 似乎我的 DNS 服務器找不到與我傳遞的 URL 關聯的地址。 我收到錯誤是因為我的 Ubuntu 子系統中沒有設置 resolv.conf 文件。

解決方案:

在 wsl Ubuntu Linux 輸入命令

sudo nano /etc/resolv.conf

添加名稱服務器並保存文件

nameserver 8.8.8.8

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM