Search code examples
pythonpandaspipseabornminiconda

why couldnot I install "seaborn" and "pandas" in ubuntu?


in my code, there are

import seaborn

and they give me

no module named seaborn

when I use

pip install seaborn

it gives me Requirement already satisfied but I still couldnot import seaborn so I use pip3 install seaborn,it reports so many errors as follow:

 Using cached https://files.pythonhosted.org/packages/2f/79/f236ab1cfde94bac03d7b58f3f2ab0b1cc71d6a8bda3b25ce370a9fe4ab1/pandas-1.0.3.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-c8lrjdqb/pandas/setup.py", line 42
        f"numpy >= {min_numpy_ver}",
                                  ^
    SyntaxError: invalid syntax

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-c8lrjdqb/pandas/

I don't know how to solve this, and I have upgraded my setuptools like:pip install --upgrade setuptools and also pip3 install --upgrade setuptools

and also I have tried conda install seaborn it looks like work well but when I run my code, it still told me no module name seaborn so how could I install seaborn on my ubuntu?

I have checked my python version by python --version it is python3.8.

Same problem also happened with install pandas*.


Solution

  • Both python2 and python3 come shipped along with Ubuntu, so installing packages with just pip might be your issue as that is the default package manager for python 2.

    Try the following in your terminal:

    $ python3 -m pip list | grep seaborn

    If you dont get an output then this shows you that seaborn hasn't been installed via pip linked to your python3 interpreter.

    It is good practice to install packages for your interpreter specifically as follows:

    $ python3 -m pip install <insert name of package here>

    Finally to check that the package has installed correctly launch the python3 interpreter within your terminal and try and import the package e.g.

    $ python3

    >>> import seaborn as sns

    Most of the packages for your python distribution should be in the following directory:

    $ cd /usr/local/lib/python3.8/dist-packages

    The above are just a few pointers to get you started, hope that helped!