LoginSignup
7
4

More than 3 years have passed since last update.

【Python】VS CodeでPythonをデバッグするとrequestsがimportできないエラーが出た

Last updated at Posted at 2019-10-08

エラー内容

最近VS Codeを触り始めたのですが、以下のようなPythonのライブラリがないエラーが発生しました。

vscode-pythonPath01.png

解決方法

簡単に方法を説明すると、vsCodeのsetting.jsonにmac内のPythonのある場所のパスを指定してあげればOK。

と言われても。。って方もいると思うので、実際にやっていきます。

まずはvsCodeの設定が書かれているsetting.jsonを開きます。

vscode-pythonPath02.png

vscode-pythonPath03.png

右上のアイコンを押すと、setting.jsonのファイルを表示できます。

ターミナルでPythonのパスを表示します。

僕は、以下のようになりました。

ターミナル
$ which python

/Users/ユーザー名/.pyenv/shims/python

変更を追記する

vscode-pythonPath04.png

デフォルトでは左記のようになっています。

右側に書くと上書きされるので、先ほどのターミナルで表示したパスを書いていきます。

以上で終了です、もう一度デバッグしてエラーが出なければ成功です!

7
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
4