How to Install Pyenv-virtualenv on Ubuntu 18.04

Reading Time: 3 minutes
python-logo

Pyenv is an outstanding tool for managing multiple Python installations. Pyenv-virtualenv is a pyenv plugin that facilitates the creation and management of Python virtual environments with pyenv. This is a compelling proposition, making it possible to manage multiple Python versions with pyenv and provide the means to control the Python environment in a more granular manner.

Preflight Check

These instructions are executed as the root user on a Liquid Web Self-Managed Ubuntu 18.04 server. It is not required to be logged in as the root user to run these commands though some may need sudo permissions.
These instructions assume pyenv is already installed and that pyenv has been used to install some version of Python. Looking for how to install pyenv? Check out our article How to Install Pyenv on Ubuntu 18.04.

Step 1: Update and Clone the Repository

It’s always a good idea before getting started installing new packages or software to make sure the system is up to date. To accomplish this, run the following command.

root@ubuntu:~# apt update -y

Once that task has finished, we can go ahead and clone the pyenv-virtualenv repository. The following command will clone the repository into the pyenv plugins directory:

root@ubuntu:~# git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv

Step 2: Configuration

This step is optional; however, it has been included because of the additional value it adds when using pyenv and pyenv-virtualenv. Running the following command will allow pyenv-virtualenv to automatically activate a virtual environment if it has been set up to do so.

root@ubuntu:~# echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc

Now to enable pyenv-virtualenv, we need to restart the shell:

root@ubuntu:~# exec “$SHELL”

Step 3: Verify the Installation

To verify that pyenv-virtualenv is working as expected, we will create a project directory, and change directories it into it.

root@ubuntu:~# mkdir python_project
root@ubuntu:~# cd python_project/
root@ubuntu:~/python_project#

Once inside the project directory, it’s time to create a virtual environment. The syntax to create a virtual environment with pyenv-virtualenv is as follows.

pyenv-virtualenv

To verify what versions of Python can be installed, run the following command.

root@ubuntu:~/python_project# pyenv versions
* system (set by /root/.pyenv/version)
3.8.3

Create a Virtual Environment

Now, to create a virtual environment we run this command.

root@ubuntu:~/python_project# pyenv virtualenv 3.8.3 python-project-3.8.3
Looking in links: /tmp/tmpuwmdca68
Requirement already satisfied: setuptools in /root/.pyenv/versions/3.8.3/envs/python-project-3.8.3/lib/python3.8/site-packages (41.2.0)
Requirement already satisfied: pip in /root/.pyenv/versions/3.8.3/envs/python-project-3.8.3/lib/python3.8/site-packages (19.2.3)

That’s it! Now recheck the available versions and the newly created virtual environment should be in the list:

root@ubuntu:~/python_project# pyenv versions
* system (set by /root/.pyenv/version)
3.8.3
3.8.3/envs/python-project-3.8.3
python-project-3.8.3

Activating and Deactivating the Virtual Environment

To make things convenient in terms of activating and deactivating this virtual environment, run the following command.

root@ubuntu:~/python_project# pyenv local python-project-3.8.3
(python-project-3.8.3) root@ubuntu:~/python_project#

You should notice that the command prompt has changed, displaying the currently activated virtual environment. The pyenv local command adds a .python-version file to the directory and lets pyenv know which python environment to use whenever the directory is entered. Changing out of this directory will automatically deactivate the virtual environment.

(python-project-3.8.3) root@ubuntu:~/python_project# cd
root@ubuntu:~#

Similarly, changing back into the directory automatically activates the virtual environment.

root@ubuntu:~# cd python_project/
(python-project-3.8.3) root@ubuntu:~/python_project#

However, this virtual environment can be used outside the project directory by invoking the pyenv activate command like so.

(python-project-3.8.3) root@ubuntu:~/python_project# cd
root@ubuntu:~# pyenv activate python-project-3.8.3
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1’ to simulate the behavior.
(python-project-3.8.3) root@ubuntu:~#

It can then be deactivated manually by running this command.

(python-project-3.8.3) root@ubuntu:~# pyenv deactivate
root@ubuntu:~#

That’s all there is to it! Pyenv, in combination with pyenv-virtualenv, makes the management of Python versions and environments a breeze. Installing multiple versions of Python on an Ubuntu system is simple and straightforward.

Having access to a tool that centralizes both the management of the Python version and the discreet environments, each of those versions has is something that saves time and makes the development process that much easier.

We pride ourselves on being The Most Helpful Humans In Hosting™!

Our support staff is always available to assist with any issues related to this article, 24 hours a day, 7 days a week 365 days a year.

We are available, via our ticketing systems at support@liquidweb.com, by phone (at 800-580-4986) or via a LiveChat or whatever method you prefer. We work hard for you so you can relax.

How to Install Pyenv on Ubuntu 18.04

Reading Time: 3 minutes

What is Pyenv?

Pyenv is a fantastic tool for installing and managing multiple Python versions. It enables a developer to quickly gain access to newer versions of Python and keeps the system clean and free of unnecessary package bloat. It also offers the ability to quickly switch from one version of Python to another, as well as specify the version of Python a given project uses and can automatically switch to that version. This tutorial covers how to install pyenv on Ubuntu 18.04.

Continue reading “How to Install Pyenv on Ubuntu 18.04”

What is Cloud Automation?

Reading Time: 4 minutes


What is Cloud Automation?

Cloud automation is a blanket term that is often used to denote specialized software, tools, and operations that help us reduce the manual effort when it comes to deploying and maintaining cloud-based IT infrastructure. Simply put, it is automating tasks programmatically.

cloud5

Did you ever wonder what happens when you place an order for a new VPS via the Liquid Web Manage Interface? Cloud Automation is behind all of that. Let’s dig in a bit deeper to learn what Cloud Automation is.

One key reason why automation is so widely embraced and used almost everywhere is that automation reduces the manual effort and intervention needed to deploy a set of tasks. Again, let’s take ordering a VPS as an example. When we placed our order before automation was in place, someone would have to manually allocate both the hardware and software resources. We would then install the OS, cPanel/WHM, and the other default server software, and we would test to make sure everything is working correctly.

Today, we can make an initial selection of our configurations based on the cloud environment of our choice, and so gain the ability to perform multiple complex tasks with a single click.

Benefits of Cloud Automation

Benefits of cloud automation are many, but I’ll list some of them so that you can get a better understanding of what Cloud Automation can do for your business and why it is a must-have if you are running an enterprise.

cloud4
  1. Agility: Businesses can scale quickly to better adapt to changing needs
  2. Speed: Increased deployment speed of cloud infrastructure and management
  3. Control: Better administration and centralized management of existing environments
  4. Security: Graduated levels of security provide more granularity when controlling permissions and access rights
  5. Resiliency: Downtime is revenue lost. The continuous monitoring of cloud services and automatic response to issues keep business processes running smoothly
  6. Change Management: Improving the CI/CD (Continuous Integration and Continuous Delivery) method ensures a better overall process cycle while lowering the possibility of software errors or a failure which increases development stability
  7. Cost: The TCO (Total Cost of Ownership) of our IT infrastructure is often significantly reduced

Once we have our automation system configured and ready for the delivery of programmed tasks, we will be able to deploy, integrate, and manage our systems quickly and effectively. Now that we know what cloud automation is and some of its benefits let’s talk about Cloud Orchestration.

Cloud Orchestration

We like to imagine Cloud Orchestration as Cloud automation evolved.
Using cloud orchestration, we can execute automated tasks at an exact time across multiple nodes. We have task A, task B, and task C. You need to run task C before B, and task A after B. Automation can handle these tasks automatically. Orchestration allows us to perform them in the correct order, in a specific timeframe with better fault-tolerant behavior.

Cloud orchestration is an ideal solution for enterprises that need to orchestrate and manage processes across hundreds of domains, systems, and teams. Now that we know the difference between automation and orchestration, it’s time to discuss some common uses of cloud automation.

cloud2

Cloud Automation Usage

Load balancing

Load balancing is the process of routing web traffic across multiple servers to ensure that resources are utilized in the best possible way. This can limit delays and improve the overall responsiveness of a site or application. Moreover, if one of our servers in a cluster goes offline, the website or application will not stop, as the rest of the servers in the cluster will take up the work for the server that went offline. Additionally, a new server can be restarted to replace the down server or service almost immediately.

Development and Testing

In today’s world, everything around us is continually evolving and changing. Think about your favorite software. Every update that comes out has to be tested in advance on multiple environments and platforms. In many cases, whole teams of developers are testing new updates. They need new settings generated directly, and this is where automation comes into play and shines. Developers can set up new environments with an OS, browser, and other tools that they need in a blink of an eye.

IaC (Infrastructure as Code)

IaC is actually one of the most common uses of automation. This process is what manages and deploys VM’s, cloud storage volumes (when you order new CBS or Object Storage platform, for example), networks, load balancers, and many other available components and services. Basically, we create templates to manage all of these functions and services and allow IaC to oversee these processes. Now that we have provided some examples of automation and its usage let’s review some of the most common cloud automation tools.

cloud1

Cloud automation tools

Kubernetes

Kubernetes is a widely used open-source system for automation used to manage containerized workloads and services. Today, all major cloud providers are offering their own branded versions of Kubernetes, including Google, Microsoft, and Amazon, to name a few.

Puppet

Puppet is one of the oldest tools in use today for use in IaC. When we are looking for a server cluster and management automation tool, Puppet meets that need. It is also an open-source software but does have an available enterprise version.

Ansible

Ansible is an IaC friendly tool developed by Red Hat. The enterprise version of this tool is called Ansible Tower, and it is capable of performing automation and orchestration tasks. We will conclude this article with Ansible.

Docker

Docker is a containerization software that is used for automating the deployment and management of applications within an isolated environment. This software allows us to “pack” and ship an application, along with all of its needed files, libraries, and dependencies, into a “docker container“. That container can then be easily ported to any Linux system that contain cgroups support within the kernel, and provides a container management environment. Docker is one of several containerization implementations (not to be confused with virtualization) based on this cgroups mechanisms built into the Linux kernel.

These are just a few of the essential tools used in cloud automation, but we have merely scratched the surface of the available devices and utilities available to us.

Overall, Cloud automation is a winning choice for many businesses if a stable, continuous, and permanent management of infrastructure is required.

Our Support Teams are replete with talented Linux technicians and System administrators who have an intimate knowledge of multiple web hosting technologies, especially those discussed in this article. If you are a Fully Managed VPS server, Cloud Dedicated, VMWare Private Cloud, Private Parent server or a Dedicated server owner and you are uncomfortable with performing any of the steps outlined, we can be reached via phone @800.580.4985, a chat or support ticket to assisting you with this process.

How To Install PyCharm on CentOS 7 and 8

Reading Time: 3 minutes

What is PyCharm?

PyCharm is an IDE (or Integrated Development Environment) for the Python programming language. It is a cross-platform development environment that is compatible with Windows, macOS, and Linux. It provides a tool that integrates code analysis, graphical debugging, unit testing, and also contains an integrated terminal that supports development on remote hosts and virtual machines.

Continue reading “How To Install PyCharm on CentOS 7 and 8”

The Best DevOps Tools for Infrastructure Automation

Reading Time: 5 minutes

Today, DevOps teams try to utilize automation as much as possible. This is to cut down on the sheer number of repeatable processes to limit man-hours worked, throttle development efforts, and to reduce the possibility of errors. This is also a business necessity to reduce overhead costs, increase the speed of the CI/CD process and increase customer satisfaction. There are multiple individual areas that need to be automated to have a fully autonomous infrastructure. Luckily, there are various tools we can take advantage of to help us automate our infrastructure and make sure we have well-developed DevOps processes. In this article we will go over the several of the best DevOps tools for our infrastructure systems.

Continue reading “The Best DevOps Tools for Infrastructure Automation”

How to Install Keras

Reading Time: 6 minutes
keras.logo.3.12.20

Keras is a Python-based high-level neural networks API that is capable of running on top TensorFlow, CNTK, or Theano frameworks used for machine learning. It can be said that Keras acts as the Python Deep Learning Library. Keras was created with emphasis on being user-friendly since the main principle behind it is “designed for human beings, not machines.” The core data structure of Keras is a model, or a way to organize layers.

Continue reading “How to Install Keras”

How To Install and Configure Wraith

Reading Time: 10 minutes

What is Wraith?

Wraith is a visual regression testing tool which uses screenshot comparisons to assess visual differences in a website over time. It is currently hosted on GitHub and available under an Apache 2.0 open-source license.

Continue reading “How To Install and Configure Wraith”

Little Known Ways To Utilize GitHub Gists

Reading Time: 5 minutes

What is Gist?

Gist is an easy method to share snippets or excerpts of data with others. A gist can be a string of code, a bash script or some other small piece of data. These bits of information are hosted by GitHub as a repository. Using gist has all the benefits of utilizing a GitHub repository, and also provides a more lightweight way of utilizing GitHub’s versioning features. 

Continue reading “Little Known Ways To Utilize GitHub Gists”

Installing Microsoft Powershell on Ubuntu 18.04

Reading Time: 5 minutes

If you are a Windows administrator who has recently been tasked with administering a Linux-based Ubuntu server, you may find that utilizing Microsoft Powershell may help ease the transition into Linux, and allow you to be more productive. If you are a Linux administrator who is interested in exploring the options that Powershell provides, then this tutorial is for you as well.

Continue reading “Installing Microsoft Powershell on Ubuntu 18.04”