How to install modules in Python 2.7 insted of Python 3.6?


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.


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


Better use virtual environment for this. Follow this link <a href="https://realpython.com/blog/python/python-virtual-environments-a-primer/" rel="nofollow">https://realpython.com/blog/python/python-virtual-environments-a-primer/</a>

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


  • (Python) Rtree intersection and fiona questions
  • Angular2 ngNoForm and also do angular form validation
  • C++ password masking
  • How do I change the kernel/python version for iPython?
  • How dotnet build chooses the output name
  • user data scripts fails without giving reason
  • Can you pass an array from javascript to asp.net mvc controller action without using a form?
  • Building Qt project for C++11 standard
  • During installation of Django, why do I keep getting ImportError: No module named django?
  • Python pickle not one-to-one: different pickles give same object
  • pillow imaging ImportError
  • Problems installing Yesod for Haskell
  • error importing numpy
  • How to Cache Real-time Data?
  • Is there a way to do normal logging with EureakLog?
  • Time complexity of a program which involves multiple variables
  • Admob requires api-13 or later can I not deploy on old API-8 phones?
  • Test if a set exists before trying to drop it
  • Spark fat jar to run multiple versions on YARN
  • Asynchronous UI Testing in Xcode With Swift
  • Scrapy recursive link crawler
  • Spring Data JPA custom method causing PropertyReferenceException
  • NetLogo BehaviorSpace - Measure runs using reporters
  • Cross-Platform Protobuf Serialization
  • Perl system calls when running as another user using sudo
  • ActionScript 2 vs ActionScript 3 performance
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • How can I estimate amount of memory left with calling System.gc()?
  • Apache 2.4 - remove | delete | uninstall
  • SVN: Merging two branches together
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • Understanding cpu registers
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How does Linux kernel interrupt the application?
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?