0

I have different versions of Python installed on my Ubuntu machine (2.7.11, 2.7.12, 3.5). I would like to install Flask on the 2.7.12 as it used by Apache.

I have three pip{version} in my PATH which are: pip, pip2, and pip2.7. How do I know which one is for which python version.

I have already read Here but it didn't help my case as I need to differentiate between minor version number 2.7.11 and 2.7.12.

One thing is that I tried pip{version} install Flask for all three pips but the 2.7.12 still can't import Flask.

Any help is much appreciate it.

Thanks

Community
  • 1
  • 1
user1941390
  • 510
  • 6
  • 18
  • 1
    Rather a comment than an answer, but this is what `virtualenv` is exactly for. – Jan Sep 14 '16 at 10:57

2 Answers2

1

You should always create virtualenvs for your projects. You can create one like

virtualenv -p <path/to/python2.7.12> <path/to/new/virtualenv/>

inside that virtualenv pip and python will always select the right interpreter and path.

Nils Werner
  • 34,832
  • 7
  • 76
  • 98
  • It seems best for now. I just wanted to use the main actual system python not virtual but I think I have to. – user1941390 Sep 14 '16 at 11:09
  • You are using the system python. But you are isolating all `pip` installed packages from your main system (which would require you to use `sudo pip` and could mess up your system). – Nils Werner Sep 14 '16 at 11:42
0

You can find it out by trying to run this: pip --version. Output will be something like this: pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7). This way we can see that it is for python2.7 in my case.

sehrob
  • 1,034
  • 12
  • 24
  • --version is not giving the minor version number. Also, I get same site-packages paths for both 2.7.11 and 2.7.12. But, if I try "iimport site; site.getsitepackages()" I will get different paths. Still struggling. – user1941390 Sep 14 '16 at 11:07