Virtual Environment in Linux

Li Yin
Li Yin
Jul 24, 2017 · 1 min read

Step by step guide to install Python 3.6 and pip3 in Ubuntu

  1. Download Python-3.6.1.tar.xz from https://www.python.org/
  2. Unzip the file and keep the folder in home directory.
  3. Open terminal in that directory and perform the following commands: ./configure make make test sudo make install
  4. This will install Python 3.6 but pip3 may not be working.Install necessary modules using:
    sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
  5. Now write the following to re run the installation: sudo make sudo make install
  6. Now you can install packages with Python 3.6 using pip3 command. For example:
    sudo pip3 install numpy

when we are in the virtual env, we can totally use either pip or pip3 to install the python packages we need. However, for packages that can not be installed with pip, for example, with apt-get, the package will be installed outside the virtualenv, PYTHONPATH must also point to the location of packages installed with apt-get. For Ubuntu this is /usr/lib/python2.7/dist-packages/

A typical PYTHONPATH variable would look like:

PYTHONPATH=/usr/lib/python2.7/dist-packages/:

So we run the following commands:

export PYTHONPATH=/usr/lib/python2.7/dist-packages/:$PYTHONPATH
Li Yin

Written by

Li Yin

Computer scientist. ✍️A book in progress@https://github.com/liyin2015/Algorithms-and-Coding-Interviews.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade