Tag Archives: debug

[Solved] panic: runtime error: invalid memory address or nil pointer dereference

Error code:

type MongoConn struct {
	clientOptions *options.ClientOptions
	client        *mongo.Client
	collections   *mongo.Collection
}

var mongoConn *MongoConn

func InitMongoConn() error{

	ctx, cancelFunc := context.WithTimeout(context.Background(), 10*time.Second)
	defer cancelFunc()

	mongoUrl := "mongodb://" + user + ":" + password + "@" + url + "/" + dbname
	mongoConn.clientOptions = options.Client().ApplyURI(mongoUrl)
	
	//......
}

To solve the problem caused by pointer assignment:

var mongoConn MongoConn

[Solved] VS Code Debug JavaScript Error: “crbug/1173575, non-JS module files deprecated”

  According to the online method (VSCODE debug Javascript), after installing the debugger for Chrome extension, debug JavaScript, the result is not able to display the web page in the browser correctly, the wrong report: “crbug/1173575, non-JS module files deprecated”, as shown in the following figure:

resolvent:

Open launch.json and change the port number in “URL” in “configurations” to the port number of live server

Save, and then press F5 again to debug normally

Upload file error analysis standardmultiparthttpservletrequest

controller

/**
 * MultipartFile Automatic encapsulation of uploaded files
 * @param email
 * @param username
 * @param headerImg
 * @param photos
 * @return
 */
@PostMapping("/upload")
public String upload(@RequestParam("email") String email,
                     @RequestParam("username") String username,
                     @RequestPart("headerImg") MultipartFile headerImg,
                     @RequestPart("photos") MultipartFile[] photos) throws IOException {

    log.info("Upload the message:email={},username={},headerImg={},photos={}",
            email,username,headerImg.getSize(),photos.length);

    if(!headerImg.isEmpty()){
        String originalFilename = headerImg.getOriginalFilename();
        headerImg.transferTo(new File("D:\\cache\\"+originalFilename));
    }

    if(photos.length > 0){
        for (MultipartFile photo : photos) {
            if(!photo.isEmpty()){
                String originalFilename = photo.getOriginalFilename();
                photo.transferTo(new File("D:\\cache\\1"+originalFilename));
            }
        }
    }


    return "main";
}

Common errors:

New file (“D: \ cache \ 1” + originalfilename “), there is no duplicate disk file name

Debug the debug mode and enter the transferto method. It is found that the source code is to judge whether the file exists

debug mode evaluate expression. Open the expression debugging window and see the error

from keras.preprocessing.text import Tokenizer error: AttributeError: module ‘tensorflow.compat.v2‘ has..

Error from keras.preprocessing.text import tokenizer: attributeerror: module ‘tensorflow. Compat. V2’ has

Import the vocabulary mapper tokenizer in keras in NLP code

from keras.preprocessing.text import Tokenizer

Execute code and report error:

AttributeError: module 'tensorflow.compat.v2' has no attribute '__ internal__'

Baidu has been looking for the same error for a long time, but it sees a similar problem. Just change the above code to:

from tensorflow.keras.preprocessing.text import Tokenizer

That’s it!

The solution of no space left on device always appears when using TF’s debug tool (tfdbg)

The first time you use tensorflow’s debug tool, but when you use it for the second time, there is always a shortage of space, which can be solved through the following steps.

  df -h

Find that the root directory is full, then go to the root directory and check the occupied directory  

  du –max-depth=1 -h

  It is found that TMP directory takes up a lot of space

 

Sure enough, when you go to TMP, you find files related to tfdbg. Just delete them  。

 

 

 

 

 

‘coroutine‘ object is not iterable [How to Solve]

ValueError: [TypeError("'coroutine' object is not iterable"), TypeError('vars() argument must have __dict__ attribute')]

In fastapi, uvloop uses asynchronous function
to use asynchronism. ‘coroutine’ object is not Iterable error
originally found that asynchronous code was called in synchronous function.

Please add async, await to the external function

About the problem of calling tools library by running Python program under Mac OS X, modulenotfoundererror: no module named ‘tools‘

ModuleNotFoundError: No module named ‘Tools’

For example, import the tools library into pcharm of MAC

from Tools.scripts.abitype import classify
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Patch
from sklearn import datasets
from minisom import MiniSom

The first line will report error!!!

It seems that it is very difficult to change the tools variable in MAC environment. The solutions are as follows

Direct import classify

import classify

The test is effective ~

Solution of OpenCV library import error in Python 3

The solution of OpenCV library import error in python3

Operating environment:

Operating system: CentOS 7.9

Software environment: Python 3.6

Error problem description:

When using OpenCV library, error occurred when importing Library:

File "<stdin>", line 1, in <module>
File "/home/summer/.local/lib/python3.6/site-packages/cv2/__init__.py", line 5, in <module>
    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

resolvent:

Enter the command in the terminal:

sudo yum update
sudo yum install mesa-libGL.x86_64

The update is complete.

Error in installing Matplotlib Library: permissionerror: [errno 13] permission denied: ‘/ usr / local / lib / python3.6’

Error occurred when downloading and installing Matplotlib Library in python3: permissionerror: [errno 13] permission denied: ‘/ usr/local/lib/python3.6’.

Operating environment:

Operating system: CentOS 7.9

Software environment: Python 3.6

Error Description: using the command PIP3 install Matplotlib to download the Matplotlib library is an error.

resolvent:

Failed to resolve: com.se renegiant:common 1.5.20

Then we found another more simple and effective way

1. From http://download.csdn.net/download/qq_ 38355313/12156696 download the common package you need

2. Directly put the required module into the LIBS folder

3. Add the original

implementation fileTree(include: ['*.jar'], dir: 'libs')

Change to

implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs') 

This problem can be solved, and the pro test is effective.

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class (through reference chain: com.jd.lean.mjp.dal.entity.Province_$$_ jvste70_ 0[“handler”])

1. Background

When using mybatis one to many collection query, an error is reported

2. Solution

One to many, entity class, with annotation
@ jsonignoreproperties (value = {“handler”})

3. Reasons

JSON serialization does not ignore some properties in the bean that do not need to be converted, such as handler

Successfully solved the problem of “runtimee” in RESNET dataset classification rror:expected scalar type Long but found Float”

Recently, I encountered some mistakes as shown in the title when doing deep learning classification, but I don’t know how to modify them. Finally, after exploration, I successfully solved them
the problems and solutions are reported directly below.

Error

Solution

In practice, the label of classification should be long, and the image should be float32
therefore, modifying the data type will succeed, but it doesn’t matter. I’ll share it with you after I solve it successfully!