2

I have two versions of Python in my laptop. Python 2.7 and Python 3.6. If install a module this is installed only in Python 3.6.

I would like to install modules in Python 2.7 through pip but I don't know how to do it.

I want to install right now GDAL and Fiona for Python 2.7 in Ubuntu 17.04.

halfer
  • 19,471
  • 17
  • 87
  • 173
José Carlos
  • 2,586
  • 9
  • 51
  • 88
  • use `pip2 install ...` – Naramsim Feb 20 '18 at 11:00
  • 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 Feb 20 '18 at 15:16

2 Answers2

4

If Python 2.7 is well installed on your system, you should have python2 and/or python2.7 commands and you could run the following:

python2.7 -m pip install <your-packages>

To make sure you are running the correct python version, you can use python2.7 --version

gogaz
  • 2,123
  • 1
  • 24
  • 30
1

Better use virtual environment for this. Follow this link https://realpython.com/blog/python/python-virtual-environments-a-primer/

You can set python version to use in virtual env using

virtualenv -p path/to/python2.7 env_name

Activate this env using . env_name/bin/activate then,

Use pip install package_name to install libraries inside virtual environment

paras_47
  • 21
  • 5