Knowledge Base
MilesWeb / Web Hosting FAQ

Learn how to configure and use a newer version of Python

Approx. read time : 3 min

This article guides you on how you can configure and use a new version of Python. You may need to do it when :
• You have a managed server account and you want to use new Python version than what is already installed on the server.

Note: This applies to all hosting accounts that have cPanel, including shared and reseller server.

• You have an unmanaged server account, and the package repositories for your Linux distribution contain an older version of Python.

Before proceeding with this article make sure that you have a compiler and other development tools installed on your server.

Let’s get started.

# Steps to configure managed servers

Your account can be located on a managed server that already has an older version of Python installed. So, if you wish to run a new version of Python, you can compile it by using this source code.
Perform the following steps to compile Python from the source code :

1. Using SSH, log in to your account.

2. Type following command in the command prompt :

cd~
wget https://www.python.org/ftp/python/3. 5. 2/Python-3. 5. 2. tgz
tar xvzf Python-3. 5. 2. tgz
cd Python-3. 5. 2
./configure --prefix=$HOME
make
make install

Note: This command explains how to install Python version 3.5.2. If you want to install a different version, then visit https://www.python.org/ftp/python/ to view the other versions that are available for download. Once you select a version, run the previous commands with the version number that you have selected at the place of 3.5.2.

3. To configure your shell environment and to use the new compiled executable, type the following command.

echo 'alias python3="/home/username/bin/python3.5" '>> ~/.bashrc
source ~/.bashrc

Replace the username with your MilesWeb hosting account username.

4. In order to confirm that your account is configured to use the new version, type the following command :

python --version

# Steps to install virtualenv

To create virtual environments by using your installed version of Python, you first need to install the virtualenv program. Type following command to do this :

cd ~/bin

python3.5 -m pip install virtualenv

You are then allowed to create a virtual environment by running the virtualenv program in the bin directory. For example: if you want to create a virtual environment named testenv, type the following command :

~/bin/virtualenv testenv

Type the following command, to activate the new environment.

source testenv/bin/activate

#Steps to configure unmanaged servers

There is a possibility that the package repositories for your Linux distribution may contain the older version of the Python. But, if you want to run the new version of Python, then you can compile it from the source code. Perform the following steps to do so:

1. Using SSH, log in to your account.

2. Type the following command in the prompt, as a root user:

cd~
wget https://www.python.org/ftp/python/3. 5. 2. Python-3. 5. 2. tgz

tar xvzf Python-3. 5. 2. tgz

cd Python-3. 5. 2

./configure

make

make install

3. In order to configure the shell environment and to use the new compiled executable, type the following command :

echo 'alias python3="/executable_path/python3.5" ' >> ~/.bashrc
source ~/ .bashrc

Replace executable_path with the path to the compiled Python executable (example, /usr/local/bin).

4. To confirm if your account is configured to use the new version, type the following command :

python --version

For more information about Python, visit https://www.python.org

Also Read :

1)How to Create the End User Access for Python and Ruby Selector?

With an interest in doing something creative daily, Sonam works as a Digital Marketing Executive. She likes to write technical blogs related to web hosting, digital marketing, and other IT topics. She also likes to spend her leisure time on social media to find different strategies for client engagement.

Trusted By Thousands of Clients & Big Businesses

We highly appreciate the kind and stellar feedback we receive from our customers. Delivering the best is our goal! MilesWeb is rated Excellent out of 5 based on reviews. Read more reviews.

Excellent
Based on reviews
2 hours ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
4 hours ago
Milesweb is superb Hosting pro...
Milesweb is superb Hosting provider ever, their Support team is amazing!!!...
Abhishek Singh
15 hours ago
Great support in great timing...
We need urgent assistance on changes in a primary domain on our client's Cpanel accounts and reached...
Riyaju Deen
21 hours ago
Best Website Hosting platform ...
I was new on MilesWeb. And needed help on multiple areas from setting up to getting started with cre...
Harshada
1 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
1 days ago
the team is very supportive th...
the team is very supportive though at times effort needs to be made to make understand the problem s...
Suree Sharma
1 days ago
I am using miles web for 3plus...
I am using miles web for 3plus years, very quick and perfect support by the team, they helped me man...
Sri Raghav
2 days ago
The service is good...
The service is good. They are answering with patience and doing the needful as soon as possible....
MR
2 days ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
3 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
4 days ago
positively helped me with find...
positively helped me with finding insecure content on my website causing SSL to not work properly on...
Thaviraj Junglee
4 days ago
Exceptional support, Truly Pra...
I had opted for the basic wordpress hosting plan as I intended to experiment with various plug-ins. ...
Aseem Chandna