VSCode pyファイルレポートUnable to import requests pylint(import-error)解決方法を開く
2005 ワード
質問の詳細:
解決策:
一、requestsはインストールされていません.インストールする必要があります.
1、コンソールにインストールコマンドを入力してインストールする:
しかし、国内に外部ネットワークがない場合はtime outのインストールに失敗します.この場合、国内のソースを変更して一時的なインストールを行う必要があります.
2、固定ソースに追加
windows:
win+Rはユーザディレクトリ%HOMEPATH%を開き、このディレクトリの下にpipフォルダを作成し、pipディレクトリの下にpipを作成する.iniファイル、内容は以下の通りです.
二、requestsがインストールされている場合
VSCodeでファイル->プリファレンス->設定を開き、Python>Linting>Pylint Argsを検索し、追加項目をクリックします.次の2つを追加します.
次の図を示します.

解決策:
一、requestsはインストールされていません.インストールする必要があります.
1、コンソールにインストールコマンドを入力してインストールする:
pip install requests
しかし、国内に外部ネットワークがない場合はtime outのインストールに失敗します.この場合、国内のソースを変更して一時的なインストールを行う必要があります.
http://mirrors.aliyun.com/pypi/simple/
https://pypi.mirrors.ustc.edu.cn/simple/
(douban) http://pypi.douban.com/simple/
https://pypi.tuna.tsinghua.edu.cn/simple/
http://pypi.mirrors.ustc.edu.cn/simp
:
pip install requests -i https://pypi.tuna.tsinghua.edu.cn/simple

2、固定ソースに追加
windows:
win+Rはユーザディレクトリ%HOMEPATH%を開き、このディレクトリの下にpipフォルダを作成し、pipディレクトリの下にpipを作成する.iniファイル、内容は以下の通りです.
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
二、requestsがインストールされている場合
VSCodeでファイル->プリファレンス->設定を開き、Python>Linting>Pylint Argsを検索し、追加項目をクリックします.次の2つを追加します.
--errors-only
--disable=E0401
次の図を示します.
