Hello everyone! Welcome to protozoahost, In this article, I am going to describe the steps to configure and set up the python version on a server.
Step 1. Configuring managed serversIn order to use the newer version of Python on the server where your files are uploaded, you need to compile python from the source code following the given steps.
- Login to your account using SSH.
- Enter the following commands at the command prompt.
cd ~ wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz tar xvzf Python-3.8.0.tgz cd Python-3.8.0 ./configure --prefix=$HOME make make install3. To use the new Compiled executable, configure your shell environment by typing the following commands:
echo 'alias python3="/home/username/bin/python3.8"' >> ~/.bashrc source ~/.bashrc Put your username instead of /username in above command. 4. Type the following command to check whether latest python version is updated or not. python3 --version
Step 2. Install VirtualenvIn order to create virtual environments using latest installed Python version, you must first install the virtualenv program, to do this, use the following commands
cd ~/bin python3.8 -m pip install virtualenvAfter you installed virtualenv, you can now create virtual environment by running the virtualenv program in the bin directory. For reference, virtual environment named testenv is created below by first command and activated by second command below.
~/bin/virtualenv testenv source testenv/bin/activate
Step 3. Configuring unmanaged serversStill, different repositories for your Linux distribution may contain an older version of Python. If you want to run a newer version of Python, you can compile it from the source code. Follow the given steps to do so.
- Log in to your account using SSH.
- As the root user, at the command prompt, type following commands:
echo 'alias python3="/executable_path/python3.8"' >> ~/.bashrc source ~/.bashrc4. To confirm the update version again, type the following command.
python3 --version That's all, hope your issue is solved by now.