0

I just upgraded from Python 3.5.2 to 3.6.5 using the instructions found here. They worked, and I now have python 3.6 installed on my system. However, when I try and execute any python scripts with imported libraries, I get this error:

Traceback (most recent call last):
  File "main.py", line 8, in <module>
    from kclass import kNearestNeighbour, euclideanDistance, getFeatureDistance
  File "/home/raovinnakota/Desktop/BioInformatics/Final_Project/kclass.py", line 10, in <module>
    from matplotlib import pyplot
ModuleNotFoundError: No module named 'matplotlib'

I used pip3 to install matplotlib again to make sure, but it says matplotlib is already installed. This same error occurs with all other imported libraries as well.

Edit: After several hours of digging around, as well as the helpful comments from below, I found the reason why this wouldn't work is that I didn't have a pip3.6 to correspond to python3.6, which was a result of not correctly installing python 3.6 in the first place. I found this, which is by far the best step-by-step approach to updated to python 3.6 from 16.04. Thanks again for everyone that responded, much appreciated.

  • 1
    Are you sure you're using the right `pip` to install? – user3483203 May 26 '18 at 05:12
  • Hmm. On some OSes you can have more than one version of Python 3 installed. I wouldn't think that would be a problem with Ubuntu. If you fire up `python3` from the terminal, what version does it report? Also, you can do `ls /usr/bin/python*` to see some of the different versions present on your system if you see more than one version of python3.x, then you might have two versions installed. – bfris May 26 '18 at 05:20
  • Yeah, I made sure to use pip3 install. This code ran fine on python 3.5 - It was only after the upgrade that I ran into the imported library errors – Rao Vinnakota May 26 '18 at 05:21
  • Did you also upgrade `pip3` via the system package manager? – gilch May 26 '18 at 05:28
  • @bfris when I run `ls /usr/bin/python*` I actually don't see anything for 3.6, but when I run `python --version` it says 3.6.5. Could that be the issue? – Rao Vinnakota May 26 '18 at 16:25

2 Answers2

1

Use python -m pip instead of just pip3 to be sure you install packages for that python.

Make sure your python launches the new version, or use whatever command does that plus the -m pip.

gilch
  • 10,813
  • 1
  • 23
  • 28
0

Since you have switched python version from 3.5 to 3.6, some libraries need to be uninstalled and then installed again. Moreover, you did not uninstall old libraries so the error is correct and you already have the wrong libraries. I think there is no need to upgrade pip version but if this doesn't work try to upgrade your pip version, then reinstall the libraries again.