Author Archives: Robins

[Solved] Logon failed, use ctrl+c to cancel basic credential prompt. unable to access

Welcome to reprint the original blog. Please attach the blog link when reprinting. Thank you for your respect.


Problem Description:

Local environment: Windows 10 system

Compiler: idea 2018.3.4

Code warehouse: GitHub

When submitting the test code with [git push], the prompt “login failed, use Ctrl + C to cancel the basic voucher” appears, as follows:

Logon failed, use ctrl+c to cancel basic credential prompt. unable to access…

Because the incident happened suddenly, only the error information was copied, and there was no screenshot to keep the certificate. Forgive me, O (╯ □ ╯) O


Cause analysis:

Ha ha, to tell you the truth, it’s really not clear.

However, after the problem was finally solved, the GitHub official website sent me an email, which roughly said that they “do not recommend using git’s password for basic authentication”.

Therefore, I have reason to suspect that this is the result of my login with GitHub account and password in idea. It is recommended to log in in in the way of “git account + token”, which should be all right.

The screenshot of the email content is as follows:


Solution:

On the [git bash] command line, enter the following command, and then push the branch again.

setx GIT_TRACE ""

My case:

There are other methods, such as [git account + token] login recommended by the government, but they are not as simple as the above method. It is not a big problem and there is no need to pay attention, so I won’t be wordy.

I hope I can help you!!

How to Solve RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu

In this case, the data and models are generally one in the CPU, one in the GPU, or the data used for calculation. Some have been put in the GPU, and some still exist in the CPU. Here is an idea.

First, find the error reporting line, see which variables or data are used in the calculation, and then use. Is_ CUDA this attribute to check which are on the GPU and which are on the CPU, and then put them on the CPU or GPU. for instance:

The error message indicates that there is a problem in line 46 of utils.py. Then enter the file and locate line 46

Print idx_ Range and reverse_ Mapping to check whether it is on the GPU or the CPU at the same time,

print(idx_ range.is_cuda,reverse_mapping.is_cuda)

After verification, IDX was found_ Range on CPU, reverse_ Mapping on GPU, idx_ Range on GPU (IDX)_ Range. To (device)), problem-solving

Flink Error: is not serializable. The object probably contains or references non serializable fields.

Today, a colleague suddenly reported such an error. At first, he really didn’t react. Member variables can’t be serialized….

Exception in thread "main" org.apache.flink.api.common.InvalidProgramException: java.lang.ref.ReferenceQueue$Lock@11fc564b is not serializable. The object probably contains or references non serializable fields.
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:151)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:71)
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.clean(StreamExecutionEnvironment.java:1821)
	at org.apache.flink.streaming.api.datastream.DataStream.clean(DataStream.java:188)
	at org.apache.flink.streaming.api.datastream.KeyedStream.process(KeyedStream.java:398)
	at org.apache.flink.streaming.api.datastream.KeyedStream.process(KeyedStream.java:374)
	at com.xintujing.flinkdemo.text.UserCount_3.main(UserCount_3.java:53)
Caused by: java.io.NotSerializableException: java.lang.ref.ReferenceQueue$Lock
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
	at org.apache.flink.util.InstantiationUtil.serializeObject(InstantiationUtil.java:586)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:133)
	... 11 more

When you see this error, you are in an ignorant state and cannot be serialized. What do you mean?

First, analyze the problem. He tells us that a class cannot be serialized,

What happens if a member in a class does not implement a serializable interface?A simple question about the Java serialization process. If you try to serialize an object that implements a serializable class, but the object contains a reference to a non serializable class, a non serializable exception notserializableexception will be thrown at run time,

Well, if you take an object as a member variable of another object, all member variables of the object must be serializable. If the member variables cannot be serialized, this error will be reported. So. Don’t treat non serializable things as member variables.

Lumen Error: Class ‘League\Flysystem\Adapter\Local‘ not found

When using the lumen framework, if file storage support is required, an error will be prompted
class’ League \ flysystem \ adapter \ local ‘not found

The main reason is the lack of extension libraries. However, remember to bring the version number
when introducing dependencies. The directory structure of the new version of League \ flysystem has changed, so that the corresponding classes cannot be found under lumen 8.0;

composer require league/flysystem:"^1.0

Push to origin/Master was rejected [How to Solve]

Today, the leader created a new git warehouse for me, and a file readme. MD
already exists in the GIT warehouse. As usual, I operate locally as follows:

git init //Initialize the repository
git add . (file name) //add the file to the local repository
git commit -m "first commit" //add file description information
git remote add origin + remote repository address //link the remote repository and create a master branch
git push -u origin master //Push files from the local repository to the remote repository

But tip:

Reason: readme.md already exists in the new git warehouse, but the files of the local warehouse and the remote warehouse have not been associated. Therefore, we first associate the files of the two warehouses and then submit them
enter the commands in the terminl window of idea

git pull
git pull origin master
git pull origin master --allow-unrelated-histories

Then push the project again to succeed
if you still report an error, you can delete the local. Git folder and re associate the file:


git init //Initialize the repository
git add . (file name) //add the file to the local repository
git commit -m "first commit" //add file description information
git remote add origin + remote repository address //link remote repository, create master branch
#Associate files
git pull
git pull origin master
git pull origin master --allow-unrelated-histories
#push the code to the remote branch
git push -u origin master //Push files from the local repository to the remote repository

Such a simple serialization system.text.json.serialization also reports an error?

Consulting area

kofifus:

I am going to switch json.net in the project to the native system. Text. JSON , but I encountered an unexpected error. The test code is as follows:


using System.Text.Json.Serialization;
using Newtonsoft.Json;

public class C {
  public C(string PracticeName) { this.PracticeName = PracticeName; }
  public string PracticeName;
}

var x = new C("1");
var json = JsonConvert.SerializeObject(x); // returns "{\"PracticeName\":\"1\"}"

var x1 = JsonConvert.DeserializeObject<C>(json); // correctly builds a C

var x2 = System.Text.Json.Serialization.JsonSerializer.Parse<C>(json);

The last line of the above code will report:


Exception thrown: 'System.NullReferenceException' in System.Text.Json.dll Object reference not set to an instance of an object.

What did I do wrong?

I found that this problem can be solved by parameterless constructor , but doing so will put the cart before the horse. Is there a flexible way to realize the simple functions that can be realized by JSON. Net .

Answer area

Christian Gollhardt:

In the . Net core 3.0 stage, the development of system. Text. JSON has not been completely completed. At present, only nonparametric constructor is supported, which may be supported in the future.

If you are migrating the old version to . Net core 3.0 , I still suggest you use newtonsoft. JSON .

    MVC

Install the microsoft.aspnetcore.mvc.newtonsoftjason package from nuget and inject it into the Services container.


services.AddMvc().AddNewtonsoftJson();

    SignalR:

InstallMicrosoft.AspNetCore.SignalR.Protocols.NewtonsoftJson package from Nuget


//Client
new HubConnectionBuilder()
.WithUrl("/chatHub")
.AddNewtonsoftJsonProtocol(...)
.Build();

//Server
services.AddSignalR().AddNewtonsoftJsonProtocol(...);

In this way, you can use json.net in . Net core 3.0 .

user11400447:

To solve this problem, you must make two changes:

praccename

    1. should be made into an attribute, not a field. Use a parameterless constructor

I wrote a console program, in which C1 is converted through newtonsoft. JSON , and C2 is converted through system. Text. JSON .


using Newtonsoft.Json;

namespace TestJsonParse
{
    class Program
    {
        static void Main(string[] args)
        {
            var c1 = new C1("1");
            var json1 = JsonConvert.SerializeObject(c1); // returns "{\"PracticeName\":\"1\"}"
            var x1 = JsonConvert.DeserializeObject<C1>(json1); // correctly builds a C1

            var c2 = new C2();
            string json2 = "{\"PracticeName\":\"1\"}";
            var x2 = System.Text.Json.Serialization.JsonSerializer.Parse<C2>(json2); // correctly builds a C2
        }

        class C1
        {
            public C1(string PracticeName) { this.PracticeName = PracticeName; }
            public string PracticeName;
        }

        class C2
        {
            public C2() { }
            public string PracticeName { get; set; }
        }
    }
}

Comment area

Times have changed. I’ve finished system.text.jason, and then I used the latest. Net 5 digression code.


namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var json = "{\"PracticeName\":\"1\"}";

            //json.net
            var x1 = JsonConvert.SerializeObject(json);

            //System.Text.Json
            var x2 = System.Text.Json.JsonSerializer.Deserialize<C>(json);

        }
    }

    public class C
    {
        public C(string PracticeName) { this.PracticeName = PracticeName; }
        public string PracticeName;
    }
}

The result is…. Continue to report errors…

What else can I say

The SDK of Android webrtc compiled with Ninja – C out / release command reported an error, and the Android NDK processing method could not be found

We have also introduced a lot about webrtc compilation before. Because GN is much faster than gyp, we use GN to generate construction scripts and Ninja to build webrtc.

GN generate Ninja command

Common commands for generating Ninja build files using GN are as follows:

// Generate a debug version of the build file, default configuration
gn gen out/Debug 

// Generate a build file for the release version
gn gen out/Release --args="is_debug=false"

Ninja script

The gyp scripts under skia \ gyp are templates. When sync and gyp is executed, the actual build scripts will be generated dynamically according to these templates. Many module dependencies and conditions can be found in gyp or gypi under this directory.

Use the Ninja – C out/release instruction to compile and report an error

When compiling the webrtc SDK required by Android using the Ninja – C out/release instruction, the following error occurred:
Ninja: entering directory ` Android/release ‘
Ninja: error:’… /…/third ‘_party/android_ ndk/sources/android/cpufeatures/cpu-features.c’, needed by ‘obj/third_ party/android_sdk/cpu_features/cpu-features.o’, missing and no known rule to make it

From this error report, we can know that there is a problem with the file dependency and the required file cannot be found. Sometimes, the project directory changes and dependencies cannot be found. For webrtc, the plug-ins that depend on will be downloaded to the third-party library in webrtc, but the cpu-features.c file cannot be found when opening the third-party library in webrtc, which indicates that webrtc lacks an Android NDK third-party.

Therefore, we need to download the required NDK from the official Android website(https://developer.android.google.cn/ndk/downloads/revision_History) and copy it to third under the webrtc directory_part/android_Inside the NDK. Then run the Ninja – C out/release command again, and the error disappears.

How to Solve Springboot Error: Failed to convert value of type

Resolved [org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type ‘java.lang.String’ to required type ‘java.lang.Integer’; nested exception is java.lang.NumberFormatException: For input string: “50.5”]

General meaning:
failed to convert the value of type “Java. Lang. string” to the required type “Java. Lang. integer”; Nested exception is java.lang.numberformatexception: for input string: “50.5”]

This kind of error is usually caused by the parameters passed by the front end and the failure of the back end parsing, that is, it is wearing illegal parameters. For example, the upper front end gives me a floating point number, and the back end will fail when the string is parsed into a number!

[Solved] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-cli) on

This problem bothered me for a while. What I want to say is that I couldn’t find the problem when deploying springboot through Maven. Therefore, after quickly arranging a springboot project, I found that the error will still be reported

So I looked at this version number and added it in and it worked
   <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
<version>2.5.3</version>
            </plugin>
        </plugins>
    </build>

[Solved] modulenotfounderror: no module named ‘torchtext.legacy.data.datasets_ utils‘

Cause: pytorch version is too low## Title
Solution.
Step 1: Find the utils.py file inside the downloaded E:\anaconda\package\envs\pytorch_gpu\Lib\site-packages\d2lzh_pytorch installation package and open it.
Step 2: Change the import torchtext inside to import torchtext.legacy as torchtext
Step 3: Close jupyter and reopen it, successfully.