Search code examples
pythontweepy

pip package install but i got SyntaxError: invalid syntax in (venv)


i used pip to install tweepy package, if i run pip list commend i see tweepy 3.3.0 there installed but when i run my code i got this error

Traceback (most recent call last):
  File "/home/ramib/Desktop/project/PracticeProject/MiningTwitterData.py", line 9, in <module>
    import tweepy
  File "/home/ramib/Desktop/project/venv/lib/python3.10/site-packages/tweepy/__init__.py", line 17, in <module>
    from tweepy.streaming import Stream, StreamListener
  File "/home/ramib/Desktop/project/venv/lib/python3.10/site-packages/tweepy/streaming.py", line 340
    def _start(self, async):
                     ^^^^^
SyntaxError: invalid syntax

Solution

  • tweepy 3.3.0 is over 8 years old and does not work on Python 3.10. async is being used as a parameter name here, but it became a keyword in Python 3.7 (having been deprecated as a variable name since Python 3.5), making such usage invalid.

    You probably want to install the latest version of tweepy instead. pip install tweepy should do this.