0

I am using Ubuntu 16.04. I have python 2.7 and python 3.7 installed on machine. I have installed pandas on my machine. However when I try to import the pandas package it gives ModuleNotFoundError: No module named 'pandas' for both the versions

The output of which python2 is /usr/bin/python2 and that of which python3 is /usr/local/bin/python3

muru
  • 193,181
  • 53
  • 473
  • 722
Sushodhan
  • 101
  • 3
  • Please add output of `which python2 ; which python3` to the question by [editing it](https://askubuntu.com/posts/1262952/edit). Are you using Anaconda? – N0rbert Jul 29 '20 at 13:07
  • @N0rbert No, I am not using Anaconda – Sushodhan Jul 29 '20 at 13:59
  • You have to remove locally installed python3 with `sudo apt-get install --reinstall python3-minimal` and `sudo rm /usr/local/bin/python3` and then retry. – N0rbert Jul 29 '20 at 14:13

1 Answers1

1

You have to remove locally installed python3 by

sudo apt-get install --reinstall python3-minimal
sudo rm /usr/local/bin/python3

and then install python bindings for Pandas with:

sudo apt-get install python-pandas python3-pandas
N0rbert
  • 97,162
  • 34
  • 239
  • 423
  • I tried the above command. I got the output as Reading package lists... Done Building dependency tree Reading state information... Done python-pandas is already the newest version (0.17.1-3ubuntu2). python3-pandas is already the newest version (0.17.1-3ubuntu2). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. It still does not work. – Sushodhan Jul 29 '20 at 13:02
  • Did you install a local custom Python 3? Because that is going to override the system Python 3 libraries and result in the issues you're seeing here. **Remove** your locally/PPA installed Python 3 from /usr/local/bin and then reinstall python3-minimal. – Thomas Ward Jul 29 '20 at 14:40
  • 1
    Anaconda can't recognize locally installed Python packages unless one of the following two conditions is met. 1. Anaconda installed the packages itself. or 2. The Ubuntu Python package is linked to a symbolic link in Anaconda's directory, so that Anaconda can recognize it as if Anaconda installed it itself. – karel Jul 29 '20 at 14:40