One place for hosting & domains


      How to Check Python Version

      Python reigns as one of the most popular programming languages, with a wide range of programs and developer tools relying on it. In fact, your system likely already has at least one version of Python installed.

      Many tools and Python development libraries require a particular version of Python. Thus, you may want to know where you can find information on your installed Python version. This can help you make decisions about compatibility, upgrades, and more.

      This tutorial shows you how to check your Python version, for both Python 2 and Python 3. Here, you can find the command line method as well as a Python script method for retrieving the current Python version.

      How to Check the Python Version from the Command Line

      The Python command comes with a command line option of --version that allows you to see your installed version.

      It works just as straightforwardly as it sounds. Enter the following command from your command line, and you should get an output similar to the one shown below:

      python --version
      Python 3.8.10

      Python 2 vs Python 3

      Some systems distinguish between Python 2 and Python 3 installations. In these cases, to check your version of Python 3, you need to use the command python3 instead of python.

      In fact, some systems use the python3 command even when they do not have Python 2 installed alongside Python 3. In these cases, you only have the python3 command.

      The command for checking the installed version of Python 3 remains otherwise the same – just use python3 with the --version option:

      python3 --version

      How to Check the Python Version from Python

      You can also check your installed Python version from within Python itself. Using either a script or the Python shell, you can use one of the code snippets below to print your Python version.

      Both options work equally well regardless of your system. The choice of which option to use really comes down to what format you want the output in.

      Using sys

      The sys module has a variable you can reference to get the current Python version. Below you can see an example of how the sys module’s version variable renders the current Python version. This code first imports the sys module then prints out the contents of the version variable:

      import sys
      3.8.10 (default, Jun 22 2022, 20:18:18)
      [GCC 9.4.0]

      As you can see, the sys.version variable contains more information about your installed Python version than just the number. For that reason, sys is a good module to turn to when you want more verbose version information.

      Using platform

      The platform module includes a function that fetches the current version of Python. The example code below uses this function to print the current Python version number. It first imports the platform module; then, the python_version function returns the version number to the print function:

      import platform

      The output from the platform.python_version is more minimal compared to the sys module’s version variable. This makes the platform module more useful for cases when you only need the version number. For example, this method helps when you want to design a program to parse the Python version and act accordingly.


      With that, you have everything you need for checking your current Python version. The steps above cover you whether you need to see the Python version from the command line or from within a Python script.

      You can continue learning about Python with our collection of
      Python guides. We cover everything from fundamental Python concepts to building Python web applications.

      Have more questions or want some help getting started? Feel free to reach out to our
      Support team.

      More Information

      You may wish to consult the following resources for additional information
      on this topic. While these are provided in the hope that they will be
      useful, please note that we cannot vouch for the accuracy or timeliness of
      externally hosted materials.

      Source link

      Git vs SVN: Pros and Cons of Each Version Control System

      Version Control Systems (VCS), like Git and SVN, track and manage code changes and provide an efficient way to collaborate on software development projects. A VCS is especially useful as a software development project grows in size and complexity, but even the simplest projects can benefit from tracking code changes with a VCS.

      Git and SVN are two of the most popular open source VCS solutions. Git has recently skyrocketed in popularity due to its use by developers collaborating on open-source projects. SVN, on the other hand, has been more commonly used in enterprise software development projects.

      This guide discusses the features and pros and cons of Git and SVN to help you choose the best VCS for your software development project.

      What is the Git Version Control System?

      is a distributed version control system. In this type of VCS, a project contributor creates a local repository that is a full clone of a central repository. With a local clone of the central repository, each contributor is able to work on the project completely offline on their own computer. When changes are ready, contributors can push and merge them with the central repository.

      Git has immense support from the open-source community. It has quickly become one of the most used version control systems for software development projects.

      What is SVN?

      Apache Subversion
      (SVN), is a centralized version control system. When working with this type of VCS, all project files exist on a central repository server. The central repository has a “trunk,” which contains the current, stable version of the project. When working on new features, contributors can make “branches” from the trunk. Each branch is stored in a sub-folder on the central repository. When changes are ready, a branch can be merged into the trunk.

      SVN has a long and successful history and stands as a titan in the version control world. It has widespread usage for enterprise projects, with features like granular access control that make it excel in that context.

      Git vs SVN: Pros and Cons

      To help you understand how these two version control solutions match up, this section walks you through the pros and cons of each.

      Git Pros and Cons

      Git’s pros are the following:

      • Operates locally. Contributors work on clones of the main repository, which they can continue to work on offline, without a network connection to the main repository. Contributors only need to connect when changes are ready to be pushed. This also helps limit network traffic to the main repository.

      • Avoids having a single point of failure. The repository is distributed in local copies, so there is less to worry about if a failure occurs on the main repository. The main repository can be restored from one of the local copies.

      • Handles merging from multiple contributors effectively. Contributors all work independently on their copies of the main repository. Git then provides a robust system for reconciling and merging each contributor’s changes. Staging is part of this, allowing contributors to focus on particular features without affecting others.

      Git’s cons are the following:

      • Has a higher learning curve. Using Git to collaborate on a project requires that you make your changes locally, stage those changes, and merge the changes back into the main branch. This process can get complicated, especially for non-technical users.

      • Lacks granular access control. Git supports applying limits on a contributor’s ability to create branches and merge changes on the main repository. However, you cannot restrict access to specific parts of the repository. Anyone with access to the repository has access to everything in the repository, with local repositories being clones of the entire codebase.

      • Does not effectively handle storing large binary files. Git cannot compress these files effectively, meaning that the repository size can grow exponentially with each change to a large binary file.

      SVN Pros and Cons

      SVN’s pros are the following:

      • Takes an easier approach. The path between
        creating a new feature branch
        and merging it into the trunk is relatively short and intuitive to grasp. This makes SVN a tool that requires less training when getting started and can be effectively taken up by non-technical contributors.

      • Facilitates a top-down approach. Since everything is centralized in an SVN repository, there is a single instance of the entire repository. This allows for granular repository access control. Each contributor’s access can be limited to particular directories and files. SVN is a good choice when you need to manage security hierarchies within a repository.

      • Efficiently stores large binary files. Teams that need to store binary files, especially when those binary files change frequently, can do so without worrying about exponential storage increases with each change. While this is not a concern for every team, this feature can be a significant boon for some workflows and version control use cases.

      SVN’s cons are the following:

      • Provides limited offline capabilities. Everything operates on a centralized repository using a client-server approach. When contributors are offline and unable to access the server, they essentially lose the ability to contribute. This also entails a higher level of traffic to the main repository’s server, since contributors have to access it constantly.

      • The centralized repository server can be a single point of failure. Since contributors do not make local copies of the entire repository, unless a backup copy is made, there is only one instance of the entire repository. If an issue occurs with the instance, such as data corruption, it can have dire repercussions on a software development project.

      Advantages of Git Over SVN

      The ability to work locally and offline is one major advantage to Git. SVN requires contributors to be connected to the main repository server, which essentially eliminates working offline.

      Git also outperforms SVN when it comes to merging and conflict resolution. Git has been designed for an open-source setting where numerous contributors may be working on the same parts of a codebase. To allow for this type of collaboration, Git has built up a robust system for resolving merge conflicts that makes the process smoother, and more manageable.

      Git’s distributed model of version control helps mitigate the potential for loss of the main repository. Since contributors clone the main repository, the risk of completely losing your main repository is greatly reduced. On the other hand, SVN’s centralized model of version control creates the potential for a single point of failure should anything happen to the main repository.

      Advantages of SVN Over Git

      SVN’s centralized repository model makes it easier to manage contributions and contributors. Git does not support codebase access restrictions — a contributor who has access to the repository has access to the entire repository. SVN, by contrast, provides granular control, allowing for limits on particular contributors down to the directory, and file levels.

      SVN also makes contributing easier. Git has robust conflict handling, but its system can often be daunting for newcomers. SVN’s system is more approachable, because the path between creating a new feature and merging it into the trunk is shorter and simpler.

      SVN wins out on some performance considerations. It handles network traffic exceptionally well. So, while contributors may have to be connected to the server to complete work, the network load for this is managed efficiently. Also, SVN compresses and stores large binaries quite efficiently. If your project includes large binary files, you might consider using SVN.

      Which Should You Use?

      Each of the version control systems covered here — SVN and Git — has its particular strengths and weaknesses. Each one fits different use cases better than the other, and neither one wins out over the other one outright.

      • Use SVN when you need a VCS that favors top-down management, easy contributions, and does not require you to work entirely offline. SVN often comes out on top for enterprise usage specifically for its granular access control, and it is the clear choice if you need to set up security hierarchies.

        To get started with SVN, be sure to read through our guide
        How to Install and Use the Subversion CLI Client

      • Use Git when you need numerous contributors to work in parallel, where you expect lots of potential merge conflicts, and when you need contributors to be able to work locally offline. Because it handles merge conflicts, Git makes sense for most open-source projects, where contributors often work without external coordination. Git shines in a wide range of environments with complex codebases and distributed teams.

        To learn more and start working with Git, check out our guide
        Getting Started with Git


      SVN and Git are both powerful version control systems that each use a different approach to managing and merging code changes. Git uses a distributed model, whereas SVN uses a centralized model. Which VCS that you choose largely depends on your software development project’s requirements. After reading this guide, you should be able to select the best version control system for your needs.

      Source link

      Why You Should Update Your PHP Version (& How to Do It)

      Regularly updating your site’s copy of WordPress ensures that your website will have a high level of performance and security. If you forget to update your site’s PHP version though, you’re leaving your site vulnerable to both hackers and potential performance bottlenecks. Yikes!

      Fortunately, it’s fairly easy to check your site’s current PHP version and proceed with upgrades if it happens to be outdated. This process can contribute to faster load times, improved security, and support for new functionality.

      This article will discuss what PHP is, and why you should consider updating it. Then, we’ll show you how to check your current PHP version and upgrade it if needed. Let’s get started!

      An Introduction to PHP

      update your PHP version

      PHP is a programming and scripting language that plays an important role in WordPress development. PHP takes data from the database and converts it into an HTML web page whenever someone visits your website.

      As a website owner, you might never need to learn PHP coding. However, after downloading WordPress, you’ll automatically receive all of the PHP files that make up WordPress core:

      WordPress folder in FTP client

      Although these files have been written for you — and are just waiting for your content, themes, and plugins — there are some scenarios where you can benefit from editing PHP files:

      Since PHP is one of the key languages behind WordPress, learning a little bit about how to work with it will open up the scope of projects that you are able to do.

      It’s likely that you won’t have to edit your PHP files. Still, learning the language can be handy for developers who wish to create new software or customizations.

      Why You Should Update Your PHP Version

      You might already be familiar with the importance of updating your WordPress, themes, and plugins. It’s also crucial to regularly update your PHP version:

      PHP 8.1 released

      Currently, WordPress recommends upgrading your PHP version to at least 7.4. This isn’t required, but older versions may have reached their end of life, meaning they no longer have active support for bug fixes or security updates.

      Here are the main benefits of upgrading your sites to the latest PHP version:

      • Better security: Older PHP versions can be more vulnerable to cyberattacks.
      • Improved performance: Upgraded PHP can improve load times through internal code improvements and reduced memory usage.
      • More support: Currently supported versions have active support, with regular bug fixes and security patches.

      Take it from our Director of IT Operations, Luke Odom:

      “Running a modern, supported, version of PHP is one of the best things you can do for the health, security, and speed of your website. Let’s compare an outdated PHP version to an old car. Sure, it will run and get you from point A to B, but without modern safety sensors, technology, fuel efficiency, and GPS navigation you may find yourself in some trouble a bit more easily.”

      Ultimately, your website will be faster and more secure when it’s running on the latest version of PHP. Many web hosts provide automatic updates for their customers, but if you’re not with one of these hosts, you can follow this manual process.

      How to Check Your Current PHP Version

      Before you get started, you should check which PHP version is currently supporting your website. If you’ve installed WordPress 5.0 or higher, you can view your PHP version in your dashboard.

      First, go to Tools > Site Health:

      WordPress Tools Site Health

      On the Site Health page, click on Info. Then find the Server section:

      view server Site Health in WordPress

      Here, you should be able to see your current PHP version:

      view your server's PHP version

      Another simple method for checking your PHP version is using your web host’s control panel. For DreamHost websites, click on the Manage button next to your domain:

      manage websites in DreamPress Panel

      Then, find the section labeled PHP. This will list your site’s PHP version:

      modify your PHP version

      The latest PHP release is 8.1. If you have a version older than 7.4 — the version that the WordPress project suggests — you can proceed with the following steps.

      Skip the line and get tips right in your inbox

      Click below to sign up for more how-to’s and tutorials just like this one, delivered to your inbox.

      marketing tips

      How to Update Your PHP Version (In 4 Easy Steps)

      Once you decide to update your version of PHP, we recommend taking a few precautions. Firstly, consider backing up your website. If anything goes wrong, you can roll back your version of PHP and then revert your site to the backed-up version.

      Next, make sure your website is fully up to date. In your dashboard, go to the Updates page and install the latest versions of WordPress, themes, and plugins:

      WordPress Proxy Cache plugin

      After taking these preventative steps, you can start manually updating your PHP version. As a simpler alternative, you can also contact your hosting provider. The host can typically handle this process for you.

      Step 1: Create a Staging Site

      Updating your PHP version can cause software conflicts on your website. Therefore, it’s wise to test the update in a staging area initially. This creates a separate, safe environment to implement changes rather than breaking your live site.

      With many hosting providers, you can create a staging site through your control panel. For this tutorial, we’ll be using the DreamHost panel.

      If you have a managed DreamHost plan, you can set up your staging site in minutes. Simply open your control panel and navigate to WordPress > Managed WordPress > Manage:

      DreamPress managed WordPress settings in PanelOn the next page, go to Staging. Then, click on Create Staging Site:

      create a one click staging site with DreamPress managed WordPress hosting

      This will set up your staging site on an automatically generated subdomain. After this, you can update your PHP version without editing your live site.

      Step 2: Change Your PHP Version

      No matter your hosting provider, you can usually change your website’s PHP version through your control panel. This process will look different based on your host, but you’ll want to look for a MultiPHP Manager or PHP Selector.

      To edit your DreamHost staging site, you can simply scroll down to the Configure PHP section. This section will list your current PHP version and the most recent update option:

      change PHP version

      To update PHP, click on Change PHP to v8.1. If successful, this section will indicate that your site is up to date:

      configure your PHP version

      Although it isn’t recommended, you can also directly modify your live website. In your DreamHost panel, go to Manage Websites. Then, scroll down to PHP and click on the arrow next to Modify:

      select PHP version in the DreamHost panel

      Lastly, select the new version you want to run on your website. Click on Change PHP Version to finish the process.

      Step 3: Look for Conflicts

      After updating your PHP version, we recommend reviewing your plugins and themes for conflicts. Upgrading PHP may cause common problems such as the White Screen of Death or 500 internal server errors.

      Whether you updated a staging environment or your live site, visit the front end to see if everything is functioning correctly. If you notice any errors after browsing the website, you’ll need to troubleshoot the issue.

      One common reason for WordPress errors is a plugin conflict. When issues arise, try deactivating all of your plugins using the Bulk Actions on your Plugins page:

      deactivate WordPress plugins

      To target the conflicting plugin, reactivate each plugin one by one. Then, you can download a similar plugin or delete it if it’s unnecessary.

      If you face additional problems like exceeded maximum execution time or maintenance mode errors, you might need to edit your wp-config.php file. This process could require more extensive troubleshooting, such as increasing your PHP memory limit.

      Step 4: Publish Changes to Your Live Site

      If you implemented a new PHP version on a staging site, it’s time to publish this change on your live website. Usually, you can do this in your host’s control panel.

      For example, DreamHost provides a simple one-click transfer of your staging data to your website. Once you’re sure you’ve targeted any potential conflicts, you can click on Publish Staging to Live:

      push staging environment to live

      This will successfully update your website’s PHP version. Since you used a staging site, you won’t have to worry about unexpected errors!

      Ready for an Upgrade?

      You might be hesitant to update your PHP version because you’re worried about breaking your site. However, PHP updates ultimately improve the security and performance of your website. You can easily avoid any conflicts by testing changes before making them live.

      To review, here are the four steps you can take to update the PHP version of your website:

      1. Create a staging site.
      2. Change your PHP version.
      3. Look for conflicts.
      4. Publish changes to your live site.

      Although you can manually update your PHP version, you might want to avoid doing this for every new development. Here at DreamHost, our Website Maintenance plans now include automatic PHP updates! This way, you can sit back, relax, and leave this process to us.

      Website and PHP Version Management Made Easy

      Let us handle the backend — we’ll manage and monitor your website so it’s safe, secure, and always up.

      website tech support

      Source link