Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas is not getting installed in Ubuntu

Tags:

python

pandas

pip

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
like image 470
Sachin Yadav Avatar asked Aug 27 '19 09:08

Sachin Yadav


1 Answers

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.

like image 51
CodeIt Avatar answered Oct 28 '22 19:10

CodeIt