Tag Archives: bash

If conditional statement in Bash reports an error [: missing `] ‘

This is my little demo

#!/bin/bash

read -p "Please input three numbers:" n1 n2 n3
if [ $n1 -gt $n2 ] && [ $n1 -gt $n3 ]
then
echo "max_num is $n1"
elif [ $n3 -gt $n2 ] && [ $n1 -lt $n3 ]
then
echo "max_num is $n3"
else
echo "max_num is $n2"
fi

The error [: missing `]] is reported mainly for the following reasons:

Spaces shall be used between if and ‘[‘, ‘[‘ and condition, ‘]’ and condition, ‘-GT’ and the number to be compared before and after;

When using relational operators’ && ‘ or ‘ | ‘in the middle, be sure to enclose the conditions before and after with square brackets.

Centos7 Install virtualenv Error bash: virtualenv: command not found…

After installing python3

1. Install virtualenv with PIP3

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple virtualenv

The above image has been installed successfully

2. Virtualenv: command not found

3. Add environment variable to solve the problem

(1) Using find/- name ‘ virtualenv.py ‘does it exist

It can be found in the figure below

(2) Add environment variable

Steps:

vim /etc/profile
# Add the following to the bottom of the file
PATH=$PATH:/usr/local/python3/bin

# is the command added to take effect
source /etc/profile

# Finally, check if the file was added successfully
echo $PATH

Example card:

(3)Reuse virtual env

# Use virtualenv to create a python3 environment with the command demo1
virtualenv --python=/usr/bin/python3 demo1
# Go to /demo1/bin under the virtual slow directory and start the virtual environment with the command
source activate

:Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

1. Problems

Write a simple single-layer neural network run MNIST handwritten numeral set, the result of each fit will appear dead kernel

For many dead kernels, first of all, don’t rush to search the Internet to find out how to solve the problem. Because the reasons are different, you should go to the bash terminal of notebook to check the error information, which is as follows:

It’s better to see a blog explaining this problem:

https://blog.csdn.net/qq_ 41185868/article/details/79127838#comments

According to the error report, first understand what AVX is

AVX is a kind of extended instruction, which needs the cooperation of CPU and protocol, but my tensorflow doesn’t support it.

2. Solutions

Maybe it’s because the Mac version of tensorflow is lower (compared with windows, it can’t be upgraded disorderly), so how to solve it?

It’s OK. I also want to find out what’s behind this, but it seems that the more I look at it, the more complicated it becomes. -It’s better to ignore the warning and run the code

Your user account isn’t allowed to install to the system rubygems solution

In today’s development process, I pulled down the code from the master and restarted the project. When I wanted to use the console, I found that I needed a password??And three times after password confirmation or crazy error.

At that time, I first thought that the RVM version was inconsistent, and then I checked the version and gem generation. When I confirmed that the RVM version was correct, and the mandatory use of sudo installation required gem install * * to install the gem package one by one, I was crazy.

The warning is as follows:

Your user account isn't allowed to install to the system RubyGems.
You can cancel this installation and run:

bundle install --path vendor/bundle

to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to RubyGems using sudo.

Or as follows:

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.

Guess why:

Rbenv wants to install gem into your system’s own ruby, but your user account does not allow the system to install rubygems, so you need to enter a password to give permission

Solution (input from the console in turn)

1 echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' &>&>~/.bashrc
2 
3 source ~/.bashrc
4 
5 ruby -v

Then it’s solved. We can continue to develop hi PI!!