Author Archives: Robins

[Solved] conda install DBUtils Error: To search for alternate channels that may provide the conda package you’re looking for

Error in CONDA install dbutils

To search for alternate channels that may provide the CONDA package you’re looking for

solution: </ font> switch to the environment to be installed in Anaconda prompt

[Solved] Pyinstaller package opencv error: ImportError: OpenCV loader: missing configuration file: [‘config.py’]. Check OpenCV installation.

Before packaging, it was OK. After upgrading pyinstaller and opencv, an error will be reported. I looked up a circle of information and found the answer on GitHub.

ImportError: OpenCV loader: missing configuration file: [‘config.py’]. Check OpenCV installation.

In

Pyinstaller 4.6
opencv Python 4.5.3.58
encountered a problem

 

Solution:

Solution 1

Reduce the opencv Python version to 4.5.3.56. This small version iteration actually changed something, resulting in packaging failure.

Solution 2

PS: I tried this method several times and failed

import cv2
print(cv2.__file__)

Execute these two sentences to find the path where CV2 is located:

D:\anaconda\64\lib\site-packages\cv2\cv2.cp38-win_ AMD64. PYD
this is my path
when packaging:

pyinstaller -F -w --key '12345678' --clean main.py --paths="D:\anaconda\64\lib\site-packages\cv2"

Remove the last file name from the path and keep the whole folder.

I suggest using the second scheme, because it is not constrained by the version, and this problem can be solved in a similar way in other packages in the future.

[Solved] Mac ffmpeg Install Error: filenotfounderror: [errno 2] no such file or directory: ‘ffmpeg’: ‘ffmpeg’

Audio processing error: filenotfounderror: [errno 2] no such file or directory: ‘ffmpeg’: ‘ffmpeg’

An error occurs when the following code is executed

import audiosegment

print("Reading in the wave file...")
seg = audiosegment.from_file("voice_data/out_11.wav")

print("Information:")
print("Channels:", seg.channels)
print("Bits per sample:", seg.sample_width * 8)
print("Sampling frequency:", seg.frame_rate)
print("Length:", seg.duration_seconds, "seconds")

print("Detecting voice...")
seg = seg.resample(sample_rate_Hz=32000, sample_width=2, channels=1)
results = seg.detect_voice()
voiced = [tup[1] for tup in results if tup[0] == 'v']
unvoiced = [tup[1] for tup in results if tup[0] == 'u']

print("Reducing voiced segments to a single wav file 'voiced.wav'")
voiced_segment = voiced[0].reduce(voiced[1:])
voiced_segment.export("voiced.wav", format="WAV")

print("Reducing unvoiced segments to a single wav file 'unvoiced.wav'")
unvoiced_segment = unvoiced[0].reduce(unvoiced[1:])
unvoiced_segment.export("unvoiced.wav", format="WAV")

Error content

Solution:
use the command: brew install ffmpeg installation. If the following problems occur, let’s continue brew install ffmpeg installation without turning off the error message.

==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:c16266957db69346464e39967d41d5198f3550423d6
############################                                              40.0%
curl: (92) HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
Error: ffmpeg: Failed to download resource "rav1e"
Download failed: https://ghcr.io/v2/homebrew/core/rav1e/blobs/sha256:c16266957db69346464e39967d41d5198f3550423d6aabfb62919975cf52ea19

After that, new error messages are found as follows:

Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/2to3
Target /usr/local/bin/2to3
already exists. You may want to remove it:
  rm '/usr/local/bin/2to3'

To force the link and overwrite all conflicting files:
  brew link --overwrite [email protected]

To list all files that would be deleted:
  brew link --overwrite --dry-run [email protected]

Follow the prompts and execute the following statements:

 rm '/usr/local/bin/2to3'
 brew link --overwrite [email protected]
 brew link --overwrite --dry-run [email protected]

[Solved] CCS compilation and debug error: Source lookup: unable to restore CPU specific source container – expecting valid source container id value.

When debugging, compile the error report and view the error information:

Source lookup: unable to restore CPU-specific source container – expecting valid source container id value.

Solution:

Delete the .launches and .settings folders and recompile.

[Solved] Mailsslsocketfactory error: Cannot find declaration to go to

1. Status. The 1.6.2 jar package is configured in Maven

The solution is to try to add Maven dependency again and replace the invalid jar package version

Finally, create the Lib package manually, copy the downloaded jar package to this directory, and then add it to the library. Add as library is successful

[Solved] Uncaught (in promise) TypeError: XXX.a is not a constructor

Tips:

Solution:

Step 1:

npm add vue-grid- [email protected] -beta1

Step 2:
Import vuegridlayout from ‘Vue grid layout’ in
mian.js

Add: .use (vuegridlayout)
createapp (APP).use (Axios).use (router).use (vuegridlayout).mount (‘#app’)

Because Vue grid layout is vue2, but you use vue3, you need to install the dependencies and related configurations of vue3

MYSQL Error: Can‘t find error-message file [How to Solve]

Installing MySQL
is running

mysqld --initialize --console

An error was encountered while

2021-11-06T18:04:30.907573Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file 'C: ofterwaresetting\mySQL\mysql-8.0.11-winx64 hare\english\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.

After checking many tutorials, I finally found that there was a problem with the escape character:
https://bugs.mysql.com/bug.php?id=90364

In short, change the path to double slash \ in my.ini file,
for example:

basedir=C:\\softerwaresetting\\mySQL\\mysql-8.0.11-winx64
datadir=C:\\softerwaresetting\\mySQL\\mysql-8.0.11-winx64\\Data
lc-messages-dir=C:\\softerwaresetting\\mySQL\\mysql-8.0.11-winx64\\share\\english

[Solved] Ubuntu Open jpg Image Error: Error interpreting JPEG image file (Not a JPEG file: starts with 0x89 0x50)

Question

The Java background receives a JPG format picture and finds that it can be opened and displayed normally under windows, but when it is opened under Ubuntu, it prompts error interpreting JPEG image file (not a JPEG file: starts with 0x89 0x50) . As shown in the following figure:

prompt that the file is not a JPEG image file, and the first two bytes of the file are 0x89 and 0x50 respectively.

Solution:

Via Wikipedia list_of_file_Signatures learned that the file signature at the beginning of these two bytes should be in PNG file format. Change the file suffix to PNG, and then open the file to display normally

for this reason, the logic for judging the file signature is added in the background interface to prevent the suffix submitted by the front end from being not the real format of the file (not limited to pictures).

For malicious files that deliberately forge file header information, the following logic cannot play a screening role.

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class filetools
{
	public final static Map<String, String> FILE_TYPE_MAP = new HashMap<String, String>();

	static
	{
		getAllFileType();
	}

	private static void getAllFileType()
	{
		FILE_TYPE_MAP.put("jpg(JFIF)", "^FFD8FFE000104A4649460001"); // jpg JFIF file format
		FILE_TYPE_MAP.put("jpg(Exif)", "^FFD8FFE1.{4}457869660000"); // jpg Exif file format
		FILE_TYPE_MAP.put("jpeg", "^FFD8FFEE"); // jpeg
		FILE_TYPE_MAP.put("png", "^89504E470D0A1A0A"); // PNG (png)
		FILE_TYPE_MAP.put("bmp", "^424D"); // Windows Bitmap (bmp)
		FILE_TYPE_MAP.put("mp4", "^000000206674797069736F6D"); // ISO Base Media file (MPEG-4)
	}

	public final static String getFileByFile(File file)
	{
		String filetyp = null;
		byte[] fileheader = new byte[15]; 
		try
		{
			InputStream is = new FileInputStream(file);
			is.read(fileheader);
			filetyp = getFileTypeByStream(fileheader);
			is.close();
		} catch (FileNotFoundException e)
		{
			e.printStackTrace();
		} catch (IOException e)
		{
			e.printStackTrace();
		}
		return filetyp;
	}

	public final static String getFileTypeByStream(byte[] b)
	{
		String filetypeHex = String.valueOf(getFileHexString(b));
		Iterator<Entry<String, String>> entryiterator = FILE_TYPE_MAP.entrySet().iterator();
		while (entryiterator.hasNext())
		{
			Entry<String, String> entry = entryiterator.next();
			String fileTypeHexValue = entry.getValue();
			Pattern p = Pattern.compile(fileTypeHexValue);
			Matcher m = p.matcher(filetypeHex.toUpperCase());

			if (m.find())
			{
				if (0 == m.start()) 
					return entry.getKey();
			}
		}
		return "unknow type";
	}

	public final static String getFileHexString(byte[] b)
	{
		StringBuilder stringBuilder = new StringBuilder();
		if (b == null || b.length <= 0)
		{
			return null;
		}
		for (int i = 0; i < b.length; i++)
		{
			int v = b[i] & 0xFF;
			String hv = Integer.toHexString(v);
			if (hv.length() < 2)
			{
				stringBuilder.append(0);
			}
			stringBuilder.append(hv);
		}
		return stringBuilder.toString();
	}

	public static void main(String[] args)
	{
		File f = new File("/home/alderaan/111.jpg");
		if (f.exists())
		{
			String filetype = getFileByFile(f);
			System.out.println(filetype);
		} else
		{
			System.out.println(f.getPath() + " not found!");
		}
	}
}