Virtual Environment in Linux
Jul 24, 2017 · 1 min read
Step by step guide to install Python 3.6 and pip3 in Ubuntu
- Download Python-3.6.1.tar.xz from https://www.python.org/
- Unzip the file and keep the folder in home directory.
- Open terminal in that directory and perform the following commands:
./configure make make test sudo make install - 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 - Now write the following to re run the installation:
sudo make sudo make install - Now you can install packages with
Python 3.6using 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