How Do You Troubleshoot the Message “ModuleNotFoundError: No module named ‘awscli'”?

Problem scenario
You try to run an AWS CLI command. But you receive this error:

‘ File “/bin/aws-cli-1.16.226/bin/aws”, line 19, in
import awscli.clidriver
ModuleNotFoundError: No module named ‘awscli’

Solution
Did you run sudo python3 setup.py install ? If you only ran the build step, this could happen.

How Do You Troubleshoot “/usr/bin/env: ‘python’: No such file or directory”?

Problem scenario
You try to run an AWS CLI command but you receive this error:
/usr/bin/env: ‘python’: No such file or directory

What should you do?

Possible Solution #1
If Python 3 is not installed, install it. You may want to see these postings:
How Do You Upgrade to Python 3.x on Ubuntu 16?
How Do You Upgrade Python 2.x to Python 3.7 in Debian or Ubuntu Linux?

How Do You Install Molecule on an Ubuntu 18.x Linux Server?

Problem scenario
You want to use Molecule to test Ansible roles. How do you install Molecule on Ubuntu 18.x with Python 3?

Solution
Prerequisites
i. You must have Docker installed. If you need assistance see this posting.
ii. You must have pip3 installed on the Docker host. sudo apt-get install -y python3-pip

Procedures
1.

How Do You Create a Dockerfile That Will Use Reserved Words Such as FROM, RUN, COPY, WORKDIR, ADD, and LABEL?

Problem scenario
You want to create your own Dockerfile. You also want to invoke reserved words such as FROM, RUN, COPY, WORKDIR, ADD, and LABEL. You want to then create a Docker image from it. You want to ultimately create a working Docker container from that image. How do you do all of this?

Solution

1. In a given directory,

How Do You Get around The AccessDeniedException Error with SonarQube?

Problem scenario
You are trying to set up SonarQube for the first time. You run this command:

bash /opt/sonarqube/bin/linux-x86-64/sonar.sh console

You see this error:

“jvm 1 | java.nio.file.AccessDeniedException: /opt/sonarqube/temp/conf/es/elasticsearch.yml”

What do you do?

Solution
Make sure that the user who is running the command has the ability to execute files in the /opt/sonarqube/ directory (or wherever the destination is that you are installing Sonarqube).

How Do You Generate 10,000 Random Numbers in a Tuple in Python?

Problem scenario
You want to generate 10,000 random numbers in a tuple. That is, you want a tuple with 10,000 numbers. The numbers can be chosen at random. How do you do this?

Solution
See this posting first and follow it: How Do You Generate 10,000 Random Numbers in a list in Python?
See this posting second and follow it: How Do You,

Why Does a Python Variable Keep Getting Assigned to 0 When the Output of the Bash Command Is a Different Number?

Problem scenario
In a Python script a variable that receives the output of a Bash command. When you run the Bash command on Linux or in a script, it works fine. But in the Python script it keeps being assigned to 0. What is wrong?

Solution

subprocess.call(“bash command”, shell=True) is NOT the same as subprocess.check_output(“bash command”, shell=True).

The subprocess.call will return a 0 if the Bash command was successful.

How Do You Make an Environmental Variable Persist through a Reboot on a Linux server?

Problem scenario
Every time a server is rebooted, you have to manually set environment variables with the “export” command. You want a variable to persist through a reboot so you do not have to do this manual work. You want a variable to be in the environment of the OS every time you log in. You want the solution to be specific to one user but you want it to work for any distribution of Linux (a Debian or Red Hat derivative including SUSE,

How Do You Troubleshoot the Groovy Error “JAVA_HOME is not defined correctly”?

One of the following situations apply to you:

Problem scenario #1
You try to run a Groovy command (e.g., groovy foobar.groovy), but you get this error:
“groovy: JAVA_HOME is not defined correctly, can not execute: /usr/lib/jvm/java-9-openjdk/bin/java”

Problem scenario #2
You get this error when you run an “hdfs” command:

ERROR: /usr/bin//bin/java is not executable.

What should you do?