TA

python 3.7에서 tweepy 오류 해결

tweepy 이용시에 이런 에러가 난다면

packages/tweepy/streaming.py”, line 358 def _start(self, async):

SyntaxError: invalid syntax

간단한 해결방법은 크게 2가지

A. downgrade python version fron 3.7 to 3.6.x

파이썬 3.7을 지우고 3.6대로 설치 후 모든 패키지 재설치 (pip install jupyter, pandas…tweepy 등)

조금 귀찮을 수 있으나 나중에 3.7이 다른 패키지와도 충돌 가능성이 있으므로 권장

B. reinstall tweepy for 3.7 releases

혹은 다 지우기 싫고 3.7을 계속 사용하고 싶다면 python 3.7을 지원하는 tweepy의 최신 버전 설치 (참고 : https://github.com/tweepy/tweepy/issues/1063)

cui로 git을 사용하고 있다면 아래의 두 줄로 해결 : 기존의 패키지 지우고 새로운 패키지 수동설치

pip uninstall tweepy
pip install -U git+https://github.com/tweepy/tweepy.git

만약 두번째 명령에서 오류가 난다면 git 명령이 cmd에 없거나 기타 여러 문제가 있을 수 있음

이때는 tweepy의 최신 git repository를 직접 받아서 설치하여 해결

# git 명령이 없다면 본인의 git 도구로 tweepy를 어딘가에 clone
git clone https://github.com/tweepy/tweepy.git

# 콘솔에서 tweepy 폴더 안으로 이동
cd tweepy

# 다음 명령어 실행
python setup.py install