Tag Archives: linux

The python version output from the command line is inconsistent with the python version in the current CONDA environment

Record a strange little problem.

         In order to complete the emotional dialogue project arranged by my tutor, I found a model from GitHub, and then configured the environment python2.7 + tensorflow1.13.1 on the server according to readme. At the beginning of training, I found that the training speed was very slow. After checking, I found that I didn’t use the GPU version of tensorflow, so I changed it to tensorflow-gpu1.13.1.

         Import error: libcublas. So. 10.0: cannot open shared object file: no such file or directory

         Very common old problem, CUDA is not installed or environment variables are not configured. I didn’t add CUDA to the environment variable here, because it’s a server in the school laboratory. It doesn’t have sudo permission and can’t modify the environment variable of the system, so I can only add the environment variable I need with the export command every time I start the terminal. For convenience, all the environment variables that need to be exported are recorded in a file. You only need the file source each time.

        After the source is completed, a strange problem appears. I output Python 3.8.5 with Python command in CONDA environment, and the python version of the environment shown in CONDA list is 2.7, as shown in the figure below. Clearly is the environment of Python 2.7, why use the python command to prompt that the current version is Python 3.8.5?I try to import tensorflow. It also prompts no module named tensorflow, which means that although it shows that I am in the dual RL master environment, I am in another environment?

         I repeatedly tried to delete the environment, create a new environment, and re install various packages. After many tests, I finally found the problem. When CONDA activate is executed, the target environment will be added to the environment variable of the current system, so when the python command is executed on the command line, the python version in the target environment will be executed. When the export command is executed, the specified environment variable will be added to the system environment variable. When the variable name is repeated, the existing environment variable will be overridden. When I use source to execute files containing many export commands, one of the export commands adds the default Python version of CONDA to the environment variables of the system, which covers the python version I activated with CONDA before. Therefore, although my CONDA shows that the python version I used is 2.7, the environment variables of the system have been covered by the export command I used later, The default version of Python is 3.8.5.

        I tested again. First add a python version to the environment variable by using export, and then use CONDA activate to activate another version of Python. Using Python on the command line, you will find that the output is the later version of Python. Therefore, you can conclude that the one added after the same variable name in the environment variable will override the existing one.

         Although it’s not a big problem, sometimes it’s this kind of energy-saving twig that keeps you from finding mistakes.

compile error: error in parse transform ‘lager_transform‘

The lager package is used in Erlang project. Version 20 was used before OTP, but now it is upgraded to version 24. There is an error in compiling make,

compile error: error in parse transform ‘lager_ transform’

Analysis shows that the lager version is low. Enter the rebar.config file and change the tag of lager to the latest version.

{lager, ".*", {git, "https://github.com/erlang-lager/lager", {tag, "3.9.1"}

Problem solving.

Reference article: https://github.com/erlio/vmq_ diversity/issues/12  

[Linux] solution: SCP different server copy file prompt permission denied, please try again

Problem Description: when using the SCP command to copy the file to another server, an error prompt appears

Permission denied, please try again.

terms of settlement

1. Check whether the SSH tool is installed, and change the corresponding configuration 1

Configuration file path: /etc/SSH/sshd_ config

Permitrootlogin no/without password
?Change to:
permitrootlogin yes

2. Check whether the permission to copy into the folder is sufficient

Check whether the folder has write permission, who is the user of the created folder and who the folder belongs to.

chmod 766 /usr/local/backup/

3. Check whether the SCP copy syntax is correct (whether the user name is correct/valid)

scp -r log [email protected] :/usr/local/backup

Please check the user name carefully

[Linux] failed to install libudev dev in Ubuntu 18.04

Recently, when compiling BlueZ source code bluez-5.58, you need to install the dependency library libudev dev.
the log is as follows:

checking for UDEV... no
configure: error: libudev >= 172 is required

The solutions are as follows:

 sudo apt-get install libudev-dev

However, due to the slow download speed of Ubuntu’s default software source, the software source was modified to install libudev dev for Tsinghua’s 20.04 source

The installation process is as follows:

➜  ~ sudo apt-get autoremove libudev-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  libudev-dev linux-hwe-5.4-headers-5.4.0-42 linux-hwe-5.4-headers-5.4.0-72
0 upgraded, 0 newly installed, 3 to remove and 1693 not upgraded.
1 not fully installed or removed.
After this operation, 142 MB disk space will be freed.
Do you want to continue?[Y/n] Y
(Reading database ... 234541 files and directories currently installed.)
Removing libudev-dev:amd64 (245.4-4ubuntu3.7) ...
Removing linux-hwe-5.4-headers-5.4.0-42 (5.4.0-42.46~18.04.1) ...
Removing linux-hwe-5.4-headers-5.4.0-72 (5.4.0-72.80~18.04.1) ...
Setting up udev (245.4-4ubuntu3.7) ...
Failed to restart udev.service: Unit systemd-udevd.service is not loaded properly: Exec format error.
See system logs and 'systemctl status udev.service' for details.
invoke-rc.d: initscript udev, action "restart" failed.
● systemd-udevd.service - udev Kernel Device Manager
   Loaded: error (Reason: Exec format error)
   Active: active (running) since Fri 2021-06-25 17:03:02 CST; 18h ago
     Docs: man:systemd-udevd.service(8)
           man:udev(7)
 Main PID: 611 (systemd-udevd)
   Status: "Processing with 24 children at max"
    Tasks: 1 (limit: 15842)
   CGroup: /system.slice/systemd-udevd.service
           └─611 /lib/systemd/systemd-udevd

Jun 26 11:05:01 t systemd[1]: systemd-udevd.service: Cannot add dependency job, ignoring: Unit systemd-udevd.service is not loaded properly: Exec format error.
Jun 26 11:06:26 t systemd[1]: systemd-udevd.service: Got notification message from PID 611, but reception is disabled.
Jun 26 11:06:57 t systemd[1]: /lib/systemd/system/systemd-udevd.service:26: Executable path is not absolute: udevadm control --reload --timeout 0
Jun 26 11:06:57 t systemd[1]: systemd-udevd.service: Cannot add dependency job, ignoring: Unit systemd-udevd.service is not loaded properly: Exec format error.
Jun 26 11:06:57 t systemd[1]: systemd-udevd.service: Cannot add dependency job, ignoring: Unit systemd-udevd.service is not loaded properly: Exec format error.
Jun 26 11:06:57 t systemd[1]: /lib/systemd/system/systemd-udevd.service:26: Executable path is not absolute: udevadm control --reload --timeout 0
Jun 26 11:06:57 t systemd[1]: systemd-udevd.service: Cannot add dependency job, ignoring: Unit systemd-udevd.service is not loaded properly: Exec format error.
Jun 26 11:06:57 t systemd[1]: systemd-udevd.service: Cannot add dependency job, ignoring: Unit systemd-udevd.service is not loaded properly: Exec format error.
Jun 26 11:06:57 t systemd[1]: /lib/systemd/system/systemd-udevd.service:26: Executable path is not absolute: udevadm control --reload --timeout 0
Jun 26 11:06:57 t systemd[1]: systemd-udevd.service: Cannot add dependency job, ignoring: Unit systemd-udevd.service is not loaded properly: Exec format error.
dpkg: error processing package udev (--configure):
 installed udev package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Errors were encountered while processing:
 udev
E: Sub-process /usr/bin/dpkg returned an error code (1)

As can be seen from the above logs, there was a problem with the installation of libudev dev. then I thought it was nothing and ignored it. As a result, the system could not start normally after restart.
later, through log analysis:

Failed to restart udev.service: Unit systemd-udevd.service is not loaded properly: Exec format error.

Guess whether the version of libudev dev does not correspond to the problem, and then remember that the software source was set before for 20.04, so switch to the official default software source and re install it

The installation log is as follows:

➜  ~ sudo apt-get install libudev-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-hwe-5.4-headers-5.4.0-42 linux-hwe-5.4-headers-5.4.0-72
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libudev1 udev
The following NEW packages will be installed:
  libudev-dev
The following packages will be upgraded:
  libudev1 udev
2 upgraded, 1 newly installed, 0 to remove and 126 not upgraded.
Need to get 1,180 kB of archives.
After this operation, 206 kB of additional disk space will be used.
Do you want to continue?[Y/n] y
Get:1 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 udev amd64 237-3ubuntu10.48 [1,103 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libudev1 amd64 237-3ubuntu10.48 [58.0 kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libudev-dev amd64 237-3ubuntu10.48 [19.1 kB]
Fetched 1,180 kB in 6s (214 kB/s)     
(Reading database ... 234373 files and directories currently installed.)
Preparing to unpack .../udev_237-3ubuntu10.48_amd64.deb ...
Unpacking udev (237-3ubuntu10.48) over (237-3ubuntu10.46) ...
Preparing to unpack .../libudev1_237-3ubuntu10.48_amd64.deb ...
Unpacking libudev1:amd64 (237-3ubuntu10.48) over (237-3ubuntu10.46) ...
Setting up libudev1:amd64 (237-3ubuntu10.48) ...
Selecting previously unselected package libudev-dev:amd64.
(Reading database ... 234373 files and directories currently installed.)
Preparing to unpack .../libudev-dev_237-3ubuntu10.48_amd64.deb ...
Unpacking libudev-dev:amd64 (237-3ubuntu10.48) ...
Setting up udev (237-3ubuntu10.48) ...
update-initramfs: deferring update (trigger activated)
Setting up libudev-dev:amd64 (237-3ubuntu10.48) ...
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
Processing triggers for systemd (237-3ubuntu10.42) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for initramfs-tools (0.130ubuntu3.9) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-74-generic

Done! Problem fix!!

Summary

In Ubuntu, it is convenient to switch the source. At the same time, we must pay attention to the problems in the process of installing the software. Here we encounter the problem of system crash caused by the failure of installing libudev dev

Apache service failed to start, semaphore not released

1. Apache failure

Because Apache has been hot deployed with reload before, some mutex semaphores may not be released, resulting in unable to apply. Sometimes, Apache will fail to start/load, and some errors will be reported as follows — & gt;

root@lry httpd]# tail error_log
[Mon Jun 28 16:34:28.797261 2021] [core:notice] [pid 31927] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Mon Jun 28 16:34:28.799903 2021] [suexec:notice] [pid 31927] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Jun 28 16:34:28.816970 2021] [core:emerg] [pid 31927] (28)No space left on device: AH00023: Couldn't create the proxy mutex 
[Mon Jun 28 16:34:28.818127 2021] [proxy:crit] [pid 31927] (28)No space left on device: AH02478: failed to create proxy mutex
[Mon Jun 28 16:34:28.818141 2021] [:emerg] [pid 31927] AH00020: Configuration Failed, exiting
[Mon Jun 28 16:37:30.133663 2021] [core:notice] [pid 32151] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Mon Jun 28 16:37:30.134915 2021] [suexec:notice] [pid 32151] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Jun 28 16:37:30.147614 2021] [core:emerg] [pid 32151] (28)No space left on device: AH00023: Couldn't create the proxy mutex 
[Mon Jun 28 16:37:30.147647 2021] [proxy:crit] [pid 32151] (28)No space left on device: AH02478: failed to create proxy mutex
[Mon Jun 28 16:37:30.147667 2021] [:emerg] [pid 32151] AH00020: Configuration Failed, exiting

2. Solutions

Then execute the following statement to release the synchronization semaphore

ipcs | grep apache | awk  '{print $2}'  >  signal.txt
for  i  in  `cat  signal.txt` ;  do  { ipcrm -s $i; } ;  done;

3. Restart Apache again

Solution to gzip: stdin: invalid compressed data — format violated error in decompressing. Tgz file under Linux

When executing the tar – zxvf xxxx.tgz command,
prompt the following information:
gzip: stdin: invalid compressed data – format violated
tar: child returned status 1
tar: error is not recoverable: exiting now
method 1

    1. reason: the compressed package is not compressed in gzip format, so there is no need to add Z instruction. Solution: use tar – xvf xxxxx.tgz command (i.e. remove Z parameter)

Method 2

      1. rename the downloaded file to tar suffix, MV xx.tgz xx.tar, and then execute the decompression command: tar – zxvf XX. Tar </ OL>

Method 3
add after WGet

 --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" 

For example:

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz"

or

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" -c -O 数据集名字 "对应的网页下载链接"

The problem of inconsistent host names in building rabbitmq on Linux

1. Environment:

centos 7.3

2. Problem description

Today, the following error occurred in the process of deploying rabbitmq as a front-end and back-end message push

$ rabbitmqctl set_permissions -p/duni ".*" ".*" ".*"

Error: unable to connect to node rabbit@bbbbdddd: nodedown

DIAGNOSTICS
===========

attempted to contact: [rabbit@bbbbdddd]

rabbit@bbbbdddd:
  * connected to epmd (port 4369) on bbbbdddd
  * epmd reports node 'rabbit' running on port 25672
  * TCP connection succeeded but Erlang distribution failed

  * Hostname mismatch: node "rabbit@localhost" believes its host is different. Please ensure that hostnames resolve the same way locally and on "rabbit@localhost"


current node details:
- node name: 'rabbitmq-cli-92@bbbbdddd'
- home dir: /var/lib/rabbitmq
- cookie hash: h6TDjQ+DgPaVGJLMjcG4TA==

I can’t connect to the host where I deployed rabbitmq bbbbdddd

3. Google

Google found the corresponding problem in stack overflow

Here we say to give rabbitmq command permission, delete the service and then re install it. After trying, I found that I can’t do it…

Continue with Google, and some people say to correct Erlang’s Cookie:

Erlang will generate two cookie files: C: windows. Erlang. Cookie and C: user. Erlang. Cookie. Check whether the contents of the two files are consistent. If not, replace one with the other.

Windows platform, er… My environment is Linux, and I didn’t find two . Erlang. Cookie files in the root directory

$ find/--name .erlang.cookie
/var/lib/rabbitmq/.erlang.cookie

So I gave up.

4. Solutions

The final solution is to set the host name and restart the rabbitmq service

# Kill the rabbitmq process first
$ ps -ef | grep rabbitmq | grep -v grep | awk '{print $2}' | xargs kill -9

# set hostname (assume host ip is: 192.168.1.1, hostname set to: mq)
$ echo 192.168.1.1 mq > /etc/hosts
$ echo rabbitmq > /etc/hostname
$ export HOSTNAME=mq

# Restart rabbitmq
$ rabbitmq-server -detached
# Start the web socket service
$ rabbitmq-plugins enable rabbitmq_management rabbitmq_web_stomp
# Set up users and give them administrator privileges
$ rabbitmqctl add_user duni duni
$ rabbitmqctl set_user_tags duni administrator
# set user directory
$ rabbitmqctl set_permissions -p/duni ".*" ".*" ".*"

Windows subsystem Ubuntu 18.04 solves SSH problem

Download 18.04 of Ubuntu in the Microsoft Store of windows, but there are some problems in SSH localhost. Refer to some information on the Internet and make the following summary

    first, you need to install sshd sudo apt get install openssh server and then modify/etc/SSH/sshd_ Two items under config file

      permitrootlogin yes permitrootlogin changed to yes passwordauthentication yes passwordauthentication changed to yes Restart SSH service /etc/init.d/ssh restart execute SSH localhost again input password should be able to SSH successfully

When executing shell script, $’r ‘: command not found appears

This kind of problem often occurs when using different systems or machines to write or modify scripts. The inconsistency of newline characters leads to this problem

Solution:
remove training sed -i 's/\r$//' filename

Explanation:
Option -i is for in-place editing, we delete the trailing \r directly in the input file. Thus be careful to type the pattern correctly.