Tag Archives: ProgrammerAH

RabbitMQ Startup Script (How to Set)

Create a new rabbitmq server script in the/etc/init. D directory

In the script, you need to modify Erlang path, daemon, control, init in path_LOG_Dir and PID_File parameter

#!/bin/sh
#
# rabbitmq-server RabbitMQ broker
#
# chkconfig: - 80 05
# description: Enable AMQP service provided by RabbitMQ
#

### BEGIN INIT INFO
# Provides:          rabbitmq-server
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Description:       RabbitMQ broker
# Short-Description: Enable AMQP service provided by RabbitMQ broker
### END INIT INFO

# Source function library.
. /etc/init.d/functions
export HOME=/root
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/erlang/bin
NAME=rabbitmq-server
#DAEMON=/usr/local/rabbitmq/rabbitmq_server-3.8.17/sbin/${NAME}
#CONTROL=/usr/local/rabbitmq/rabbitmq_server-3.8.17/sbin/rabbitmqctl
DAEMON=/usr/local/rabbitmq/rabbitmq_server-3.8.17/sbin/${NAME}
CONTROL=/usr/local/rabbitmq/rabbitmq_server-3.8.17/sbin/rabbitmqctl
DESC=rabbitmq-server
USER=root
ROTATE_SUFFIX=
INIT_LOG_DIR=/usr/local/rabbitmq/rabbitmq_server-3.8.17/var/log/rabbitmq
PID_FILE=/usr/local/rabbitmq/rabbitmq_server-3.8.17/var/run/rabbitmq/pid

START_PROG="daemon"
LOCK_FILE=/var/lock/subsys/$NAME

test -x $DAEMON || exit 0
test -x $CONTROL || exit 0

RETVAL=0
set -e

[ -f /etc/default/${NAME} ] && . /etc/default/${NAME}

ensure_pid_dir () {
    PID_DIR=`dirname ${PID_FILE}`
    if [ ! -d ${PID_DIR} ] ; then
        mkdir -p ${PID_DIR}
        chown -R ${USER}:${USER} ${PID_DIR}
        chmod 755 ${PID_DIR}
    fi
}

remove_pid () {
    rm -f ${PID_FILE}
    rmdir `dirname ${PID_FILE}` || :
}

start_rabbitmq () {
    status_rabbitmq quiet
    if [ $RETVAL = 0 ] ; then
        echo RabbitMQ is currently running
    else
        RETVAL=0
        ensure_pid_dir
        set +e
        RABBITMQ_PID_FILE=$PID_FILE $START_PROG $DAEMON \
            > "${INIT_LOG_DIR}/startup_log" \
            2> "${INIT_LOG_DIR}/startup_err" \
            0<&- &
        $CONTROL wait $PID_FILE >/dev/null 2>&1
        RETVAL=$?
        set -e
        case "$RETVAL" in
            0)
                echo SUCCESS
                if [ -n "$LOCK_FILE" ] ; then
                    touch $LOCK_FILE
                fi
                ;;
            *)
                remove_pid
                echo FAILED - check ${INIT_LOG_DIR}/startup_\{log, _err\}
                RETVAL=1
                ;;
        esac
    fi
}

stop_rabbitmq () {
    status_rabbitmq quiet
    if [ $RETVAL = 0 ] ; then
        set +e
        $CONTROL stop ${PID_FILE} > ${INIT_LOG_DIR}/shutdown_log 2> ${INIT_LOG_DIR}/shutdown_err
        RETVAL=$?
        set -e
        if [ $RETVAL = 0 ] ; then
            remove_pid
            if [ -n "$LOCK_FILE" ] ; then
                rm -f $LOCK_FILE
            fi
        else
            echo FAILED - check ${INIT_LOG_DIR}/shutdown_log, _err
        fi
    else
        echo RabbitMQ is not running
        RETVAL=0
    fi
}

status_rabbitmq() {
    set +e
    if [ "$1" != "quiet" ] ; then
        $CONTROL status 2>&1
    else
        $CONTROL status > /dev/null 2>&1
    fi
    if [ $?!= 0 ] ; then
        RETVAL=3
    fi
    set -e
}

rotate_logs_rabbitmq() {
    set +e
    $CONTROL rotate_logs ${ROTATE_SUFFIX}
    if [ $?!= 0 ] ; then
        RETVAL=1
    fi
    set -e
}

restart_running_rabbitmq () {
    status_rabbitmq quiet
    if [ $RETVAL = 0 ] ; then
        restart_rabbitmq
    else
        echo RabbitMQ is not runnning
        RETVAL=0
    fi
}

restart_rabbitmq() {
    stop_rabbitmq
    start_rabbitmq
}

case "$1" in
    start)
        echo -n "Starting $DESC: "
        start_rabbitmq
        echo "$NAME."
        ;;
    stop)
        echo -n "Stopping $DESC: "
        stop_rabbitmq
        echo "$NAME."
        ;;
    status)
        status_rabbitmq
        ;;
    rotate-logs)
        echo -n "Rotating log files for $DESC: "
        rotate_logs_rabbitmq
        ;;
    force-reload|reload|restart)
        echo -n "Restarting $DESC: "
        restart_rabbitmq
        echo "$NAME."
        ;;
    try-restart)
        echo -n "Restarting $DESC: "
        restart_running_rabbitmq
        echo "$NAME."
        ;;
    *)
        echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
        RETVAL=1
        ;;
esac

exit $RETVAL

Set permissions

chmod a+x /etc/init.d/rabbitmq-server

StartUp Actions Manager

chkconfig --add /etc/init.d/rabbitmq-server

Rabbitmq Sweatshirt: https://blog.csdn.net/qq_39135287/article/details/95725385

ZABBIX agent failed to start

1. Journalctl – Xe print job for zabbix-agent.service failed because a configured resource limit was exceeded

2. Journal CTL – Xe print PID… Not runnable

resolvent:

Check whether there is a folder named ZABBIX in the/run directory. If not, create a new one

# mkdir zabbix

Then start ZABBIX  
# systemctl start   zabbix-agent

# systemctl status zabbix-agent

The Java command could not find or load the main class

1. First of all, to determine whether it is an environmental variable

If you input javac command and Java command in the command line, you can output a lot of things, which means that there is no problem in the configuration of environment variables. Otherwise, you need to configure environment variables

First, create a new Java_ The value of the home variable is the installation path of JDK. For example, my value is “D:// developtools/Java/JDK”. The contents in quotation marks, excluding quotation marks, are the same below.

Then add% Java after the path variable_ Home% \ bin “and% Java_ HOME%\jre\bin”

Create a new classpath variable with the value of “.”,% JAVA_ HOME%\lib;% JAVA_ HOME%\lib\tools.jar;”

The environment variables are configured.

2. If the path of the java file is correct, it is still reported that Java cannot find or load the main class, that is the problem of the package name. CMD locates in the SRC folder of the module, calls the Java command, and the bytecode file name is with the package name

That’s it

 

Threejs is used in Vue to introduce error reporting problem of orbitcontrols

I checked many methods on the Internet, and all of them introduced the orbitcontrols in the example. However, these methods I use now report errors. The specific problem may be that the versions are different, and I don’t particularly study them in depth. At this moment, the method I use is to introduce three orbitcontrols, which can be tested by myself

import * as THREE from "three";
import { OrbitControls } from 'three-orbitcontrols-ts';


const controls = new OrbitControls(camera, renderer.domElement);

Note: many methods are temporarily feasible, more often need to verify!

Node Sass version 6.0.1 is incompatible with ^4.0.0.

Node sass version 6.0.0 is not compatible with ^ 4.0.0
1. Uninstall the previous version of node sass
NPM install node sass
2. Install version 4.0.0 after uninstall
NPM install [email protected]
Here may fail, because you install the Taobao image problem.

If it fails, reload the Taobao image
NPM install – G cnpm — registry= https://registry.npm.taobao.org
After reassembling, perform the second step again

npm install [email protected]

Restart the project NPM run dev

Syntax Error: SassError: Invalid CSS after “…-height: #{math“: expected expression (e.g. 1px, bold

Syntax Error: SassError: Invalid CSS after "...-height: #{math": expected expression (e.g. 1px, bold), was ".div($--input-heigh"
        on line 142 of node_modules/element-plus/packages/theme-chalk/src/input-number.scss
        from line 13 of node_modules/element-plus/packages/theme-chalk/src/index.scss
        from line 10 of src/assets/css/element-variables.scss
        from line 1 of src/assets/css/global.scss
>>       line-height: #{math.div($--input-height - 2, 2)};

   -------------------------^

terms of settlement

npm i sass-loader node-sass --save-dev

The installation of docker desktop failed. After successful installation, the docker can not be started

First of all, I installed it successfully, but I couldn’t start it. The error is as follows

docker An error occurred  
First, see if virtualization is turned on

If not, open Baidu by itself. Tip: can I open the meeting here   CPU model, motherboard model, windows system version, some versions just can’t be turned on. Then if the version is OK   All the settings in BIOS and windows system must be turned on at the same time.

Can’t you open it?

Try the link below

https://blog.csdn.net/ruibin_ cao/article/details/80959954

After I went through the above steps, I still reported an error, but I had no choice but to reload docker.

And this time, I can’t even fit it

Failed with the following error:
component communityinstaller.serviceaction failed: failed to start service:  
The service did not respond to the start or control request in a timely fashion at CommunityInstaller.Service.Service.< StartAsync> d__ 29.MoveNext() — End of stack trace from previous location where exception was thrown —  
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)  
at CommunityInstaller.Service.Manager.< AddServiceAsync> d__ 23.
the following methods have been tried

https://blog.csdn.net/fenger_ c/article/details/114800687

https://blog.csdn.net/weixin_ 42787754/article/details/104209345

https://www.cnblogs.com/zhiqsyr/p/12364124.html

Useless, but so far, the status is: computer virtualization has been turned on, docker related files have been deleted.

Every time I install, I check the option of opening virtualization in docker at the beginning. I think it is already opened, so I don’t check it here, so I check this option, and then install OK, open OK and run OK..

How to display the Chinese name and installation time of installed software in snmp4j walk Windows


import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import org.snmp4j.CommunityTarget;
import org.snmp4j.Snmp;
import org.snmp4j.Target;
import org.snmp4j.TransportMapping;
import org.snmp4j.mp.SnmpConstants;
import org.snmp4j.smi.Address;
import org.snmp4j.smi.GenericAddress;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.VariableBinding;
import org.snmp4j.transport.DefaultUdpTransportMapping;
import org.snmp4j.util.DefaultPDUFactory;
import org.snmp4j.util.TreeEvent;
import org.snmp4j.util.TreeUtils;

public class SnmpWalk2 {

	private static int[] octetStringToBytes(String value_ipar) {
		// ---------------------------
		// Split string into its parts
		// ---------------------------
		String[] bytes;
		bytes = value_ipar.split("[^0-9A-Fa-f]");

		// -----------------
		// Initialize result
		// -----------------
		int[] result;
		result = new int[bytes.length];

		// -------------
		// Convert bytes
		// -------------
		int counter;
		for (counter = 0; counter < bytes.length; counter++)
			result[counter] = Integer.parseInt(bytes[counter], 16);

		// ----
		// Done
		// ----
		return (result);

	}
	// octetString 转 Date

	private static Date octetStringToDate(String value_ipar) throws Exception {
		// ---------------------------
		// Convert into array of bytes
		// ---------------------------
		int[] bytes;
		bytes = octetStringToBytes(value_ipar);

		// -----------------------
		// Maybe nothing specified
		// -----------------------
		if (bytes[0] == 0)
			return (null);

		// ------------------
		// Extract parameters
		// ------------------
		int year;
		int month;
		int day;
		int hour;
		int minute;
		int second;
		int deci_sec = 0;
		int offset = 0;
		year = (bytes[0] * 256) + bytes[1];
		month = bytes[2];
		day = bytes[3];
		hour = bytes[4];
		minute = bytes[5];
		second = bytes[6];
		if (bytes.length >= 8)
			deci_sec = bytes[7];
		if (bytes.length >= 10) {
			offset = bytes[9] * 60;
			if (bytes.length >= 11)
				offset += bytes[10];
			if (bytes[8] == '-')
				offset = -offset;
			offset *= 60 * 1000;
		}

		// ------------------------------------
		// Get current DST and time zone offset
		// ------------------------------------
		Calendar calendar;
		int my_dst;
		int my_zone;
		calendar = Calendar.getInstance();
		my_dst = calendar.get(Calendar.DST_OFFSET);
		my_zone = calendar.get(Calendar.ZONE_OFFSET);

		// ----------------------------------
		// Compose result
		// Month to be converted into 0-based
		// ----------------------------------
		calendar.clear();
		calendar.set(Calendar.YEAR, year);
		calendar.set(Calendar.MONTH, month - 1);
		calendar.set(Calendar.DAY_OF_MONTH, day);
		calendar.set(Calendar.HOUR_OF_DAY, hour);
		calendar.set(Calendar.MINUTE, minute);
		calendar.set(Calendar.SECOND, second);
		calendar.set(Calendar.MILLISECOND, deci_sec * 100);

		// ---------
		// Reset DST
		// ---------
		calendar.add(Calendar.MILLISECOND, my_dst);

		// -----------------------------------------------------------------------------------
		// If the offset is set, we have to convert the time using the offset of
		// our time zone
		// -----------------------------------------------------------------------------------
		if (offset != 0) {
			int delta;
			delta = my_zone - offset;
			calendar.add(Calendar.MILLISECOND, delta);
		}

		// -------------
		// Return result
		// -------------
		return (calendar.getTime());

	}

	// octetString 转 中文

	private static String getChinese(String variable) {
		String result = variable;

		if (!variable.contains(":")) {
			return result;
		}

		if (result.equals(variable)) {
			try {

				String[] temps = variable.split(":");
				byte[] bs = new byte[temps.length];
				for (int i = 0; i < temps.length; i++)
					bs[i] = (byte) Integer.parseInt(temps[i], 16);
				result = new String(bs, "gbk");
			} catch (Exception ex) {

			}
		}
		return result;

	}

	public static void main(String[] args) throws Exception {
		CommunityTarget target = new CommunityTarget();
		target.setCommunity(new OctetString("public"));
		target.setAddress(GenericAddress.parse("udp:127.0.0.1/161")); // supply your own IP and port
		target.setRetries(2);
		target.setTimeout(1500);
		target.setVersion(SnmpConstants.version2c);

		Map<String, String> result = doWalk(".1.3.6.1.2.1.25.6.3.1", target); // ifTable, mib-2 interfaces

		for (Map.Entry<String, String> entry : result.entrySet()) {

			if (entry.getKey().startsWith(".1.3.6.1.2.1.25.6.3.1.2")) {
				System.out.println("name" + entry.getKey().replace(".1.3.6.1.2.1.25.6.3.1.2", "") + ": "
						+ getChinese(entry.getValue()));
			}
			if (entry.getKey().startsWith(".1.3.6.1.2.1.25.6.3.1.4")) {
				System.out.println("type" + entry.getKey().replace(".1.3.6.1.2.1.25.6.3.1.4", "") + ": "
						+ getChinese(entry.getValue()));
			}
			if (entry.getKey().startsWith(".1.3.6.1.2.1.25.6.3.1.5")) {
				System.out.println("datetime" + entry.getKey().replace(".1.3.6.1.2.1.25.6.3.1.5", "") + ": "
						+ octetStringToDate(entry.getValue()));
			}
		}
	}

	public static Map<String, String> doWalk(String tableOid, Target target) throws IOException {
		Map<String, String> result = new TreeMap<>();
		TransportMapping<?extends Address> transport = new DefaultUdpTransportMapping();
		Snmp snmp = new Snmp(transport);
		transport.listen();

		TreeUtils treeUtils = new TreeUtils(snmp, new DefaultPDUFactory());
		List<TreeEvent> events = treeUtils.getSubtree(target, new OID(tableOid));
		if (events == null || events.size() == 0) {
			System.out.println("Error: Unable to read table...");
			return result;
		}

		for (TreeEvent event : events) {
			if (event == null) {
				continue;
			}
			if (event.isError()) {
				System.out.println("Error: table OID [" + tableOid + "] " + event.getErrorMessage());
				continue;
			}

			VariableBinding[] varBindings = event.getVariableBindings();
			if (varBindings == null || varBindings.length == 0) {
				continue;
			}
			for (VariableBinding varBinding : varBindings) {
				if (varBinding == null) {
					continue;
				}

				result.put("." + varBinding.getOid().toString(), varBinding.getVariable().toString());
			}

		}
		snmp.close();

		return result;
	}

}

Python netmiko library Cisco telnet switch automation

import time
from netmiko import *
import sys
import os
import getpass

# Read the ip address in the iplist.txt file
iplist = open('iplist_cisco.txt', 'r', encoding='ascii')
ip_addr = iplist.readlines()
iplist.close()

cmdlist = open('cmdlist_cisco.txt', 'r', encoding='ascii')
cmd_line = cmdlist.readlines()
cmdlist.close()

# Iterate through the ip_addr list to connect to the ip
for ip in iter(ip_addr):
    print(ip)
    try:
        S5130 = {
            'device_type': 'cisco_ios_telnet',
            'ip': ip,
            'username': 'cisco',
            'password': 'cisco',
        }
        net_connect = ConnectHandler(**S5130)

        for cmd in iter(cmd_line):
            cmd_result = net_connect.send_command(cmd)
            print('-----------------------------------------------------------------')
            print(cmd)
            print(cmd_result)
            print('-----------------------------------------------------------------')
            print('')
        net_connect.disconnect()
    except (EOFError, NetMikoTimeoutException):
        print('Can not connect to Device')
    except (EOFError, NetMikoAuthenticationException):
        print('username/password wrong!')

The solution of no such file or directory and cannot load native module running error of python3 pyinstaller after packaging

 

use  Pyinstaller is often used to package python3 programs   No such file or directory   Or cannot load native module error is because the required file is not entered into the final execution file. In this case, the parameter is needed when using pyinstaller  — Add binary and add code in the entry file function to solve the problem

Example 1. No such file or directory error   — Add binary parameter solution

Package the portal Python file:

pyinstaller -F -w test.py

Run the packaged executable file:

[root@0109c795032d src]# ./dist/test
Traceback (most recent call last):
  File "test.py", line 19, in <module>
    from salt.client.ssh import ssh_py_shim
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller/test/pyimod03_importers.py", line 540, in exec_module
  File "salt/client/ssh/__init__.py", line 205, in <module>
  File "salt/utils/files.py", line 396, in fopen
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/_MEIudOUhL/salt/client/ssh/ssh_py_shim.pyc'
[5034] Failed to execute script test

By reporting an error, you can see that the file is missing, and it will be increased when pyinstall  — Add binary parameter, as follows:

pyinstaller -F -w test.py \
--add-binary="/opt/python3/lib/python*/site-packages/salt/client/ssh/ssh_py_shim.py:salt/client/ssh"

Parameter explanation:

–The syntax of add binary is: – add binary  & lt; SRC; DEST or SRC:DEST>
SRC is the packaged executable file. The missing file is in the local location,

Dest is the location of the directory that needs to be dynamically copied to when running the executable file. Dest is the relative directory,

The absolute path of the packaged execution file is from  / tmp/_ MEIudOUhL/   It started here_ Meiudouhl is generated automatically, different every time

Dest just needs to write the relative directory. For example, here is   salt/client/ssh

The final absolute path is  / tmp/_ MEIudOUhL/salt/client/ssh
The separator of SRC and dest is colon in Linux and semicolon in windows;

Adding this parameter means that the   ssh_ py_ The shim.py file is packaged into an executable file and dynamically released to a relative directory at runtime   Salt/client/SSH, so as to solve the problem that the error prompt can not find the file

Note:

The error in the error prompt cannot be found   ssh_ py_ Shim. PyC, but the   ssh_ py_ shim.py

This is because salt/client/SSH is the penultimate layer in the whole function call stack/__ init__. Py has the following code:

if not is_windows():
    shim_file = os.path.join(os.path.dirname(__file__), "ssh_py_shim.py")
    if not os.path.exists(shim_file):
        # On esky builds we only have the .pyc file
        shim_file += "c"
    with salt.utils.files.fopen(shim_file) as ssh_py_shim:
        SSH_PY_SHIM = ssh_py_shim.read()

You can see that   ssh_ py_ The shim. Py file is also available, so just find it   ssh_ py_ Shim.py or   ssh_ py_ Shim.pyc in  ” Salt/utils/files. Py “, line 396   No file not found error occurs in fopen function

Example of official website:

https://pyinstaller.readthedocs.io/en/stable/usage.html#shortening -the-command

There are a number of them  — Examples of using Add binary and other related parameters

Example 2. Cannot load native module error forced introduction solution

The error of pyinstall after packing and running is as follows:

  File "test/test.py", line 41, in init_test
  File "salt/transport/client.py", line 27, in factory
  File "salt/utils/asynchronous.py", line 70, in __init__
  File "salt/transport/client.py", line 131, in factory
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller/test/pyimod03_importers.py", line 540, in exec_module
  File "salt/transport/zeromq.py", line 23, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller/test/pyimod03_importers.py", line 540, in exec_module
  File "salt/crypt.py", line 65, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller/test/pyimod03_importers.py", line 540, in exec_module
  File "Cryptodome/Cipher/__init__.py", line 27, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller/test/pyimod03_importers.py", line 540, in exec_module
  File "Cryptodome/Cipher/_mode_ecb.py", line 35, in <module>
  File "Cryptodome/Util/_raw_api.py", line 297, in load_pycryptodome_raw_lib
OSError: Cannot load native module 'Cryptodome.Cipher._raw_ecb': Trying '_raw_ecb.cpython-39-x86_64-linux-gnu.so': cannot load library '/tmp/_MEIPh0VXD/Cryptodome/Util/../Cipher/_raw_ecb.cpython-39-x86_64-linux-gnu.so': /tmp/_MEIPh0VXD/Cryptodome/Util/../Cipher/_raw_ecb.cpython-39-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called '/tmp/_MEIPh0VXD/Cryptodome/Util/../Cipher/_raw_ecb.cpython-39-x86_64-linux-gnu.so', Trying '_raw_ecb.abi3.so': cannot load library '/tmp/_MEIPh0VXD/Cryptodome/Util/../Cipher/_raw_ecb.abi3.so': /tmp/_MEIPh0VXD/Cryptodome/Util/../Cipher/_raw_ecb.abi3.so: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called '/tmp/_MEIPh0VXD/Cryptodome/Util/../Cipher/_raw_ecb.abi3.so', Trying '_raw_ecb.so': cannot load library '/tmp/_MEIPh0VXD/Cryptodome/Util/../Cipher/_raw_ecb.so': /tmp/_MEIPh0VXD/Cryptodome/Util/../Cipher/_raw_ecb.so: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called '/tmp/_MEIPh0VXD/Cryptodome/Util/../Cipher/_raw_ecb.so'

This error also started missing files, missing  _raw_ecb.cpython-39-x86_ 64 Linux gnu.so or  _raw_ecb.so   First, add binary

pyinstaller -F -w test.py \
--add-binary="/opt/python3/lib/python*/site-packages/Crypto/Cipher/_raw_ecb.cpython-39-x86_64-linux-gnu.so:Cryptodome/Util/../Cipher"

When running in package or reporting this error, repeatedly check that the source file destination address is correct,

At this point   Copy references in later projects _raw_ECB error code to the entry function

Let pyinstaller know that I can use it  _raw_ecb.cpython-39-x86_64-linux-gnu.so to force the package of this so file

The code is as follows:

if __name__ == "__main__":
    try:
        ip = "127.0.0.1"
        port = 1234

        config = {
            'id': 'root',
            'log_level': 'debug',
            'master_ip': ip ,
            'master_port': port,
            'auth_timeout': 5,
            'auth_tries': 1,
            'master_uri': f'tcp://{ip}:{port}'
        }

        salt.transport.client.ReqChannel.factory(config, crypt='clear')
    except Exception as e:
        pass

Package with pyinstall

pyinstaller -F -w test.py \
--add-binary="/opt/python3/lib/python*/site-packages/Crypto/Cipher/_raw_ecb.cpython-39-x86_64-linux-gnu.so:Cryptodome/Util/../Cipher"

Not at this time  — Add binary should be OK, not tested

Summary

In case of errors, the general idea is to use the function call stack to push backward,

If the file cannot be found, it can be used
1. — add binary parameter

2. Compulsory introduction

To solve the problem

[Solved] Runtimeerror: CUDA error: device side assert triggered

The questions are as follows:

1. The problems are as follows:

RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_ LAUNCH_ BLOCKING=1.

2. Solution:

(1) At the beginning, I searched for solutions on the Internet. As a result, most netizens’ solutions are similar to this:

Some people say that the reason for this problem is that there are tags exceeding the number of categories in the training data when doing the classification task. For example: if you set up a total of 8 classes, but there is 9 in the tag in the training data, this error will be reported. So here’s the problem. There’s a trap. If the tag in the training data contains 0, the above error will also be reported. This is very weird. Generally, we start counting from 0, but in Python, the category labels below 0 have to report an error. So if the category label starts from 0, add 1 to all category labels.

Python scans the train itself_ Each folder under path (each type of picture is under its category folder), and map each class to a numerical value. For example, there are four categories, and the category label is [0,1,2,3]. In the second classification, the label is mapped to [0,1], but in the fourth classification, the label is mapped to [1,2,3,4], so an error will be reported.

(2) In fact, it’s useless for me to solve the same problem that I still report an error. Later, I looked up the code carefully and found that it was not the label that didn’t match the category of the classification, but there was a problem with the code of the last layer of the network. If you want to output the categories, you should fill in the categories.

 self.outlayer = nn.Linear(256 * 1 * 1, 3)  # The final fully connected layer

# Others are 3 categories, while mine is 5 categories, corrected here to solve

 self.outlayer = nn.Linear(256 * 1 * 1, 5) # The last fully connected layer

(3) It’s actually a small problem, but it’s been working for a long time. Let’s make a record here. The actual situation after the solution: