Steps | Description |
---|---|
Add Deadsnakes PPA | This involves adding an external repository that contains different Python versions. |
Install desired Version (Python 3.6.5) | Here you specify the actual Python version you want to install. |
Update Alternatives | This enables you to have multiple installations and manage the default version among them. |
Select Default Python Version | This is where you set Python 3.6.5 as the default Python version on your Ubuntu system. |
Let’s delve deeper into the process.
First, we add the Deadsnakes PPA to our Ubuntu system which is an external repository containing various Python versions. You can do this using the following command in your terminal:
sudo add-apt-repository ppa:deadsnakes/ppa
Next, we install our desired version, Python 3.6.5. Ensure you update and refresh your repositories before you start the installation process:
sudo apt-get update sudo apt-get install python3.6
We then update-alternatives to enable us to select Python 3.6.5 as the main Python alternative in our system. Run the commands:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
Finally, we use the update-alternatives tool to redirect all executions of Python on our system to Python 3.6.5 as follows:
sudo update-alternatives --set python3 /usr/bin/python3.6
Remember to verify if Python has been downgraded successfully by checking the version:
python3 -V
That’s it! Your Python version should now be 3.6.5 on your Ubuntu system. Always ensure that any active virtual environments or applications are compatible with this new Python version to prevent potential issues.
When it comes to Python versions, you might often hear coders saying “The newer, the better”. In general, upgrading ensures your code stays current with the latest language features and performance improvements. However, there are instances when downgrading becomes necessary.
A particular version of Python, say Python 3.7.5, may have unique features unvailable in other versions but these features may be incompatible with certain packages or libraries that were written for lower versions, like Python 3.6.5. Therefore, if you’re working on a legacy project that depends on these packages, downgrading your Python could be the best solution.
Equally, some applications or modules, having been developed and tested under a specific version of Python, may experience issues and conflict when confronted with a newer version. Issues can range from syntax errors, due to deprecated functions in the latest Python version, to logic errors as result of changes in the language semantics.
Now, If you are a Ubuntu user who needs to downgrade from Python 3.7.5 to Python 3.6.5, you can follow this step-by-step guideline:
- Step 1: Uninstall Python 3.7
Before installing an old version of Python, we must first uninstall the existing one. Here’s how to do it:sudo apt-get remove python3.7
- Step 2: Refresh your package lists
After removing Python 3.7, you need to refresh your local package index to reflect the changes.sudo apt-get update
- Step 3: Download Python 3.6
Let’s download Python 3.6.5 via wget command.wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
This will download Python 3.6.5 package into your system.
- Step 4: Extract the downloaded package
This can be done using tar command.tar xvf Python-3.6.5.tgz
- Step 5: Compile and Install Python 3.6
You have to navigate inside the extracted directory and then execute the configure script which prepares the software to be compiled in your operating system environment. Afterward, make altinstall is used to prevent replacing the default python binary file /usr/bin/python.cd Python-3.6.5/ ./configure make sudo make altinstall
We have now successfully downgraded our Python version to 3.6.5. You can verify this by running:
python3.6 -V
If correctly installed, the version number Python 3.6.5 should be displayed.
Note: It’s always advisable to use a virtual environment (venv) while coding so as not to mess up the system’s Python version.
This method allows for the co-existence of multiple Python versions on a single system giving developers the flexibility to switch between environments according to their project requirements. An added advantage is that venv creates isolated spaces for each application, thus avoiding potential conflicts between installed packages.
Downgrading Python versions, especially when you have scripts and projects associated with both the existing version and the one you’re downgrading to, can be quite complex. But, when performed carefully following detailed steps, it becomes considerably straightforward.
Step 1 – Verify Existing Python Version
Begin by verifying your existing installed Python version using the terminal command:
python --version
If your current Python version is 3.7.5, as indicated in this context, it should return:
Python 3.7.5. If it returns a different version, adjust your plans accordingly.
Step 2 – Install Python 3.6.5
Run these commands sequentially to update the packages index on your system and to install Python 3.6.5:
sudo apt-get update sudo apt-get install python3.6
Note: You may need to add ppa:deadsnakes/ppa to your repositories if Ubuntu doesn’t find Python 3.6.5.
Step 3 – Check the Installation of Python 3.6.5
Type the following command to verify Python 3.6.5 installation:
python3.6 --version
This should respond by showing “Python 3.6.5” as the Python version. This way, you can ensure that Python 3.6.5 has been successfully installed while keeping the existing Python 3.7.5 intact.
Step 4 – Make Python 3.6.5 Default Python Version
This step may seem cumbersome but is necessary to ensure all your future activities use Python 3.6.5 by default. Use the alternatives system to set the default Python version:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
Step 5 – Verify the Default Python Version
Final validation comes by checking the default Python version, which should now be Python 3.6.5:
python --version
Remember: Always have backups of your data and know the consequences of each step before performing operations like software downgrades. There’s always a potential risk of breaking dependencies, so proceed with caution.
It’s also worth noting that multiple versions of Python can co-exist in a system without conflicts. It’s possible to use them separately specifying their full path or using virtual environments for different projects.
To reference any code from an older Python version, explicit calling comes handy as such:
/usr/bin/python3.6 your_script.py
For streamlining this process in future, consider exploring Python version management tools like pyenv which lets you switch between multiple Python versions more easily.
Step | Action |
---|---|
1 | Verify current Python version |
2 | Update package list and install Python 3.6 |
3 | Check the installation of Python 3.6 |
4 | Switch the default Python version to 3.6 |
5 | Verify that Python 3.6 is the default version |
Performing a Python downgrade involves carefully taking into consideration a variety of aspects to ensure the process is smooth and effective. One of the most important considerations is the impact on existing projects. Python variations have different libraries and frameworks, hence a downgrade might affect the functionality of existing code bases severely.
Secondly, it’s crucial to remember that some applications installed in your system might rely on the higher version of python you are about to downgrade, so they could end up being affected. Always ensure that these applications have support for the lower version.
Let’s go through the steps involved in a Python downgrade from version 3.7.5 to 3.6.5 on an Ubuntu machine. This guide assumes that Python is already installed on the Linux machine.
1. The first step involves confirming the current version of Python installed in your system. You can obtain this information using the following command:
python3 --version
If successful, the output will be: ‘Python 3.7.5’.
2. Next, follow this step to install Python 3.6.5 from the Debian’s repository.
sudo apt-get install python3.6
3. Afterward, we need to set up Python 3.6 as the default Python version for our shell session. Accomplishing this task requires altering the PATH environment variable, such that when we type ‘python’ at the command line, our shell looks for Python 3.6 first before looking for other installed versions. Run the following command to change the PATH variable:
alias python=/usr/bin/python3.6
4. Lastly, let’s confirm if the changes were successful:
python --version
If successful, the output should be: ‘Python 3.6.5’.
Downgrading your Python version needs careful planning. Ensure appropriate programming backups exist in any case of unintended consequences. Further, adequately verify compatibility of downgraded versions with existing packages. It is also advisable to consult detailed guides on how to manage multiple versions of Python in a single machine, which can provide a more flexible working environment.
In certain scenarios, utilizing virtual environments such as those provided by Virtualenv or Anaconda, instead of downgrading Python might be a safer and preferable solution.
This approach helps manage project-specific dependencies and differing Python versions effectively without affecting the global Python installation. Creating a new virtual environment with the specific version of Python required is clear-cut:
virtualenv -p /usr/bin/python3.6 myenv
This way, your main Python installation remains untouched, and each project can customize its owned isolated environment as needed.
It is key to consider the performance implications and dependency conflicts that may arise when juggling between multiple Python versions concurrently. Therefore, it is often recommended to use Python’s virtual environments to avoid such issues. These tools allow developers to run multiple Python instances with varying versions thus promoting efficient management of resources while maintaining reliable operational accuracy.Downgrading your version of Python from 3.7.5 to 3.6.5 in Ubuntu might appear a daunting task, particularly if you aren’t accustomed to manipulating software versions or working with the terminal’s command line interface. Luckily, the process isn’t as complicated as it may look, and when executed with care, it poses minimal risks to your system.
The first step is to install the required lower version (Python 3.6.5). Although Python has a package named Pyenv that allows multiple Python versions, we’ll be using ‘update-alternatives’ for simplicity. To make this installation happen, input following commands in your terminal:
sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt-get install python3.6
Now, let’s update our alternative Python configuration and see what options we currently have:
sudo update-alternatives --config python3
If Python 3.6.5 shows up on the list displayed by this command, you can switch between Python versions by clicking their corresponding numbers and pressing ‘Enter’. However, it might not show up initially, and you need to manually add it through these commands:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
At this point, each time you need to switch between Python versions, you can use
sudo update-alternatives --config python3
.
However, it’s crucial to keep in mind potential issues that could arise during this downgrade process. The main concern would be breaking software dependencies on your system since these packages might depend on a specific Python version.
- Broken Dependencies: Various applications on Ubuntu interact with Python. If they rely on features available only in Python 3.7.5 and not in Python 3.6.5, those applications may stop functioning correctly after the downgrade. Applications generally specify which Python version they need, but there is always a risk.
- Manual Modifications: Some custom scripts or third-party programs installed could also stop working if not suitable with Python 3.6.5. Manual modifications from the user might lead to unwanted circumstances.
- Library Incompatibility: Among many libraries supported by Python, few libraries got deprecated or have hidden bugs on earlier Python versions. This kind of issue may halt your tasks from getting processed.
Most importantly, bear in mind that Python is integral to lots of fundamental Ubuntu features. Therefore, always ensure that your changes do not disrupt essential operations on your computer.(source)
Hence, while it’s feasible to downgrade Python from 3.7.5 to 3.6.5 on an Ubuntu system, it’s vitally important to weigh the benefits against potential drawbacks. Moreover, If it’s possible to execute your script or application in a virtual environment using Python 3.6.5, it’s advisable to choose that route to circumvent potential wider problems with your system.
Indeed, downgrading Python from version 3.7.5 to 3.6.5 on Ubuntu may seem like big task but truthfully, it’s reasonably straightforward with a clear path to be followed.
Following these steps outlined above:
sudo update-alternatives --remove python /usr/bin/python3.7 sudo update-alternatives --install /usr/bin/python3 python /usr/bin/python3.6 2
This gives you the power to direct your system to default to this new version of Python. It’s critical to understand that when you execute
--remove
, you’re completely detaching python 3.7 from the alternatives system for your ‘python’ command. By executing
--install
right after, we replace it with python 3.6 and setting it as the preferred version.
However, one crucial point to note is that this method does not remove the Python 3.7.5 that is installed in your system. You should keep in mind not to remove Python 3.7 entirely if it came preinstalled with your OS because Linux systems use Python for many auxiliary operations, removing the Python version it expects to find can take down the whole system.
In the spirit of safeguarding system integrity, utilizing programming environments such as Anaconda, Virtualenv or Pyenv should be considered.
Anaconda
For instance, with Anaconda/Miniconda, you can create an environment with any version of Python independently of what your system has installed.
conda create -n myenv python=3.6.5
Virtualenv
The same possibility exists for the use of Virtualenv.
virtualenv -p python3.6 myenv
Pyenv
And then there’s pyenv, which allows you to also manage different versions of Python.
pyenv install 3.6.5 pyenv global 3.6.5
At last, always remember coding is as vast as it’s versatile and there are always multiple solutions. Feel free to experiment different approaches, just be sure you fully comprehend the implications before implementing any changes to your compiler settings or configurations. To know more about managing python versions, refer here.