Atlantic.Net Blog

How to: Python 3 and Creating a Virtual Environment(venv) in CentOS 6.7

Andrew Mora
by Atlantic.Net (6posts) under VPS Hosting
Verified and Tested 02/26/15


This article covers the installation of Python 3.4 on a CentOS 6.7 operating system and how to create a Virtual Environment(venv) with pyvenv for which Python 3 can run. It is important to note the directories that we are installing is Python 3.4. CentOS 6.x is dependent on Python 2.x to function properly, do not overwrite the Python 2 installation accidentally. If you still need to install Python 2, follow our how-to on this here.


You’ll need to yum install the following packets to meet all the Python 3 and PIP dependencies:

–¬†You need a CentOS 6.7 server. If you do not have a server already, you can spin up a dependable virtual private server from Atlantic.Net in under 30 seconds.

– “Development Tools” “Development Libraries”

– readline-devel

– openssl-devel

Installing Python 3 from source on CentOS 6.7

Install build tools

yum groupinstall "Development Tools" "Development Libraries"

Install readline-devel so that your keyboard arrow keys work when entering the Python3 interactive terminal

yum -y install readline-devel

Install OpenSSL-devel for pip3

yum -y openssl-devel

Download Latest source code from Python, at the time of writing

cd /opt

Unpack and enter Python-3.4.3 directory

tar xzvf Python-3.4.3.tgz
cd Python-3.4.3

Build compile environment

./configure --prefix=/opt/python3.4.3
make && make install

Creating a Virtual Environment in CentOS 6.7

You’ll see that Python3 has been installed into /opt/python3.4.3. Note that by installing Python3, you have not altered anything with your original python. This is done purposely, if you install Python3 on top of your current Python2.x installation, you’ll break your operating system. This is why we are going to build a Virtual Environment for which we can run python3. This allows you to make changes to your Python3 installation without altering the OS’s version of python3. This is useful if different apps require different versions of Python. It also keeps you from accidentally overwriting your OS’s Python2 files.

Use the Python3 script called pyvenv locate in /opt/python3.4.3/bin/ to create your environment. We’ll create our environment in /home/ and call it py3venv, it will be created automatically if it doesn’t already exist.

/opt/python3.4.3/bin/pyvenv /home/py3venv

To start and/or enter into your virtual Python3 environment execute the following. Your command shell will change to reflect that you are in your virtual environment.

source /home/py3venv/bin/activate 
(py3venv) [[email protected]]#

Once inside the virtual environment, you may use PIP to install any additional packages you may require without affecting the system-wide instance of your Python 3 installation.
To exit the virtual environment perform the following to drop back into your normal shell:

(py3venv) [[email protected]]# deactivate
[[email protected]]#

Thank you for following along and feel free to check back with us for further updates or learn more about our reliable VPS hosting servers.

Get A Free To Use Cloud VPS

Free Tier Includes:
G2.1GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year

Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G2.1GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year

New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4


London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom