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.
JavaScript
x
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
JavaScript
import sys
import pandas as pd sys.path.insert(0, "/usr/lib/python2.7/site-packages") //error message here
Advertisement
Answer
JavaScript
import pandas as pd sys.path.insert(0, "/usr/lib/python2.7/site-packages")
This line contains two statements. Split them into two lines:
JavaScript
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!!!):
JavaScript
import pandas as pd; sys.path.insert(0, "/usr/lib/python2.7/site-packages")