VSCodeでPathの設定が上手くいきません。

実現したいこと

  • MacでVSCodeを使ってPythonのコードを書きたい。

前提

元々WindowsでVSCodeを使ってコードを書いていました。持ち出し用にM2 MacBookを購入したのでPython開発環境を作ろうとしたのですが上手くいきません。
手順としてはBrewをインストール→Brewでpyenvをインストール→pyenvでPython 3.11.1をインストール→BrewでVSCodeをインストールしました。

発生している問題・エラーメッセージ

ModuleNotFoundError: No module named 'tweepy'

tweepyの下は波線になっておらず色が付いてるので入ってると思ったのですが、機能しませんでした。

該当のソースコード

動作確認用に最後のツイートを取得するだけのコードです。

Python

1import tweepy 2 3api_key = 'VxgWMA0UJ97t2eiCQOWXZvsXp'4api_key_secret = 'bSNFOI4FF2SvZAUWOprGWMaX5CuvCBW1cX4oWezGzcuWohgVPU'5access_token = '1143677050911252480-UIyOwmd59xcd7fQJ9LP2bukbWWiUM3'6access_token_secret = 'NvxQmetYAGm4CIGkole0uLVJ30f8Zffzu0X9Y6DnynAOS'7 8# Twitterの認証9auth = tweepy.OAuthHandler(api_key, api_key_secret)10auth.set_access_token(access_token, access_token_secret)11api = tweepy.API(auth, wait_on_rate_limit=True)12 13#最後のツイートを取得14last_tweet = api.user_timeline(count=1)[0]15print('------------------')16print(last_tweet.text)

試したこと

  • pipでtweepyのインストール
zsh: command not found: pip

-pip3でtweepyのインストール

Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: tweepy in /Users/username/Library/Python/3.9/lib/python/site-packages (4.12.1) Requirement already satisfied: requests<3,>=2.27.0 in /Users/username/Library/Python/3.9/lib/python/site-packages (from tweepy) (2.28.2) Requirement already satisfied: oauthlib<4,>=3.2.0 in /Users/username/Library/Python/3.9/lib/python/site-packages (from tweepy) (3.2.2) Requirement already satisfied: requests-oauthlib<2,>=1.2.0 in /Users/username/Library/Python/3.9/lib/python/site-packages (from tweepy) (1.3.1) Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/username/Library/Python/3.9/lib/python/site-packages (from requests<3,>=2.27.0->tweepy) (1.26.14) Requirement already satisfied: idna<4,>=2.5 in /Users/username/Library/Python/3.9/lib/python/site-packages (from requests<3,>=2.27.0->tweepy) (3.4) Requirement already satisfied: charset-normalizer<4,>=2 in /Users/username/Library/Python/3.9/lib/python/site-packages (from requests<3,>=2.27.0->tweepy) (2.1.1) Requirement already satisfied: certifi>=2017.4.17 in /Users/username/Library/Python/3.9/lib/python/site-packages (from requests<3,>=2.27.0->tweepy) (2022.12.7)
  • 設定でPython > Auto Complete:Extra Pathにpipで表示された/Users/username/Library/Python/3.9/lib/python/site-packagesを追加。3.9になってるのが疑問です。

補足情報(FW/ツールのバージョンなど)

ここにより詳細な情報を記載してください。

コメントを投稿

0 コメント