6

I am trying to install the pandas library on my ubuntu machine but it is not getting installed.

pip install pandas pip3 install pandas 

I have used pip install pandas

Downloading/unpacking pandas Downloading pandas-0.25.1.tar.gz (12.6MB): 12.6MB downloaded Running setup.py (path:/tmp/pip-build-WzvvgM/pandas/setup.py) egg_info for package pandas Traceback (most recent call last): File "<string>", line 17, in <module> File "/tmp/pip-build-WzvvgM/pandas/setup.py", line 21, in <module> import versioneer File "versioneer.py", line 1629 print("Adding sample versioneer config to setup.cfg", file=sys.stderr) ^ SyntaxError: invalid syntax Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 17, in <module> File "/tmp/pip-build-WzvvgM/pandas/setup.py", line 21, in <module> import versioneer File "versioneer.py", line 1629 print("Adding sample versioneer config to setup.cfg", file=sys.stderr) ^ SyntaxError: invalid syntax ---------------------------------------- Cleaning up... Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-WzvvgM/pandas Storing debug log for failure in /home/user508/.pip/pip.log 
3
  • What is python -V and pip --version? Commented Aug 27, 2019 at 9:17
  • 2
    Looks like installing for Python 2 to me - pandas>=0.25 dropped support for Python 2.7 and all Python 3 versions before 3.5, so use pip install "pandas<0.25" for that matter. Commented Aug 27, 2019 at 9:22
  • I think that use pipenv or virtualvenv can avoid this problem. Commented Aug 27, 2019 at 12:36

1 Answer 1

6

From the error log it is clear that the OP is using an unsupported version of python. That is the reason why PIP is trying to install pandas using pandas-0.25.1.tar.gz file.

Another hint is in this line,

print("Adding sample versioneer config to setup.cfg", file=sys.stderr) ^ 

which is giving

SyntaxError: invalid syntax 

This error clearly indicates that OP is using Python 2.x. The above print statement is that of Python 3.x and it returns error when used in Python 2.x. See this repl for example.


Pandas library has dropped support for python version < 3.5.3. See the supported versions from their official doc. It states,

Officially Python 3.5.3 and above, 3.6, and 3.7.

According to their PyPI page,

The most recent version which supports python version < 3.5.3 is 0.24.2.

You can install it using the below command.

pip install pandas==0.24.2 

Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date.

Sign up to request clarification or add additional context in comments.

1 Comment

Just a note: the pandas installation requires numpy, and you will need a version compatible with python 2.x as well. I believe pip install numpy==1.16.3 gives you the most up-to-date version compatible with Python 2.x.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.