0

I have two versions of python ( 2.7 and 3.6.4) installed on ubuntu 16.04. Now I only want to work on 3.6.

I want to install few packages like pandas and psycopg2.

I tried to install it with pip3 install pandas and it shows successfully installed. However, when I am trying to import from python 3.6 it is throwing me this error:

ModuleNotFoundError: No module named 'pandas'. 

Now the question is how to tell installer (pip/pip3) to install all packages under python3.6 so that I can import the installed packages?

baduker
  • 19,152
  • 9
  • 33
  • 56
Tarun K
  • 469
  • 9
  • 20
  • How are you checking by importing? make sure you are checking it in python 3.6 – Daniyal Syed Mar 15 '18 at 11:08
  • pip3 install package under python 2, maybe you just not succeed to install it – Yu Jiaao Mar 15 '18 at 11:08
  • yes, i am checking under python3.6 console – Tarun K Mar 15 '18 at 11:09
  • Possible duplicate of [How to run pip of different version of python using python command?](https://stackoverflow.com/questions/34803040/how-to-run-pip-of-different-version-of-python-using-python-command) – phd Mar 15 '18 at 19:47

3 Answers3

1

python3 -m pip install pandas

This is advice from Raymond Hettinger.

Oleg Butuzov
  • 4,795
  • 2
  • 24
  • 33
  • i got `Requirement already satisfied` whereas when i am trying to import pandas from python3.6 console i am getting same error – Tarun K Mar 15 '18 at 11:13
  • What you can do is to check what's actually version you running, and where pandas was installed. You can try to run `-m pip freeze` with `python3.6`, `python3` and `python` commands (like `python3.6 -m pip freeze`). Maybe you have some extra install? – Oleg Butuzov Mar 15 '18 at 11:19
  • not able to locate `pandas` anywhere, i used `whereis pandas` got nothing :( – Tarun K Mar 15 '18 at 11:31
0

Have you tried virtual environments?

revelant documentation

Create a python3.6 virtual environment and activate it and work on that

Thalish Sajeed
  • 1,351
  • 11
  • 25
0

You can install it for python 3.6 using:

pip3.6 install pandas

But a better way to work with different versions of python would be to use virtual environments. Look into anaconda: https://conda.io/docs/ or virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/

Ankur Ankan
  • 2,953
  • 2
  • 23
  • 38
  • @TarunK This might help: https://stackoverflow.com/questions/30993086/pip3-command-not-found-but-python3-pip-is-already-installed. And still I would very strongly suggest to move to conda. :D – Ankur Ankan Mar 15 '18 at 11:12
  • well last week i tried conda but things are still not working, well all i want is to work on python3.6 and need to remove all versions . – Tarun K Mar 15 '18 at 11:14