I got this error message when trying to get path for Pandas package. I’m using Centos 7 for my project. Pandas already installed in the system. I’m using Python 2.7.10.
File "analyze_tweets.py", line 8 import pandas as pd sys.path.insert(0, "/usr/lib/python2.7/site-packages") ^ SyntaxError: invalid syntax
My code
import sys import pandas as pd sys.path.insert(0, "/usr/lib/python2.7/site-packages") //error message here
Advertisement
Answer
import pandas as pd sys.path.insert(0, "/usr/lib/python2.7/site-packages")
This line contains two statements. Split them into two lines:
import pandas as pd sys.path.insert(0, "/usr/lib/python2.7/site-packages")
Or, if they must be in one line, separate them with semicolon (highly not recomended!!!):
import pandas as pd; sys.path.insert(0, "/usr/lib/python2.7/site-packages")