Tag Archives: development language

Error creating bean with name ‘captchaController‘: Unsatisfied dependency expressed through field ‘c

Error creating bean with name 'captchaController': Unsatisfied dependency expressed through field 'configService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysConfigServiceImpl': Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is org.springframework.data.redis.connection.PoolException: Could not get a resource from the pool; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost:6379
Check start Redis or not

[Solved] ERROR: While executing gem … (Gem::FilePermissionError)

Environment: MAC.

When learning rails, follow the official documents. Errors may be reported at this step

 gem install rails

ERROR: While executing gem … (Gem::FilePermissionError)

Even if sudo is used to force the installation, an error will be reported in the next step.

rails new blog

`auth_ data=’: couldn’t set additional authenticated data

Solution:

Installing Ruby under MacOS – 🎄 Adomikao Yu Yongjian

The reason for the error is that the MAC installs ruby in the/usr/bin directory by default. This directory has strict permissions, resulting in code execution failure. The solution is to use RVM to install ruby in the user directory without affecting the system environment.

[Modified] AttributeError: ‘socket‘ object has no attribute ‘ioctl‘ python linux

For beginners of python, refer to the common codes on the Internet to set the heartbeat of TCP:

def __ init__ (self, IP=”127.0.0.1″, Port=5555):

“” “initialize object” “”

self.code_mode = “utf-8”    # Transceiving data encoding/decoding format

self.IP = IP

self.Port = Port

self.my_socket =socket(AF_INET, SOCK_STREAM)   # Create socket

self.my_socket.setsockopt(SOL_SOCKET,SO_KEEPALIVE,True)

self.my_socket.ioctl(SIO_KEEPALIVE_VALS,(1,10000,1000))

Run error:

AttributeError: ‘socket’ object has no attribute ‘ioctl’

It is found that there are no exceptions marked in VSC, and the rewritten code can be automatically supplemented, indicating that socket has this function. I checked that there is no relevant wrong information on the Internet, which may be due to my lack of TCP related common sense. This is confirmed by opening the socket.ioctl definition of Python. The definition is as follows:

if sys.platform == “win32”:

def ioctl(self, __control: int, __option: int | tuple[int, int, int] | bool) -> None: …

To sum up: I write code with vs in win7 and upload it to Linux for operation, while IOCTL is only valid in window.

Under Linux, it should be changed to

self.my_socket.setsockopt(SOL_SOCKET,SO_KEEPALIVE,True)

# self.my_socket.ioctl(SIO_KEEPALIVE_VALS,(1,10000,1000))

self.my_ socket.setsockopt(IPPROTO_TCP, TCP_KEEPIDLE, 10)

self.my_socket.setsockopt(IPPROTO_TCP, TCP_KEEPINTVL, 3)

self.my_socket.setsockopt(IPPROTO_TCP, TCP_KEEPCNT, 5)

[Solved] Python Django error: error: (1146, “Table ‘mydb.django_session’ doesn’t exist”)

error: (1146, "Table 'mydb.django_session' doesn't exist")

Because there is no Django in the database table_session.

Execute the command at the terminal to migrate the data structure

$ python manage.py migrate

After executing the above command, the output results are all OK. You can see that many tables have been added to the database table, The details are as follows

# By default 10 tables are automatically created in our database, as follows.
MariaDB [mydemo]> show tables;
+----------------------------+
| Tables_in_mydemo           |
+----------------------------+
| auth_group                 |
| auth_group_permissions     |
| auth_permission            |
| auth_user                  |
| auth_user_groups           |
| auth_user_user_permissions |
| django_admin_log           |
| django_content_type        |
| django_migrations          |
| django_session             |
| stu                        |
+----------------------------+
11 rows in set (0.00 sec)

Then it was solved

[Solved] Training yolov5 Error: attributeerror: can get attribute sppf on Module

Problem Description:

There was a problem running the yolov5-train.py file:

Attributeerror: cant get attribute sppf on module models.common… (followed by file path)

Solution:

1. Double click to open the common.py file:

2. Add code:

import warnings

class SPPF(nn.Module):
    # Spatial Pyramid Pooling - Fast (SPPF) layer for YOLOv5 by Glenn Jocher
    def __init__(self, c1, c2, k=5):  # equivalent to SPP(k=(5, 9, 13))
        super().__init__()
        c_ = c1 // 2  # hidden channels
        self.cv1 = Conv(c1, c_, 1, 1)
        self.cv2 = Conv(c_ * 4, c2, 1, 1)
        self.m = nn.MaxPool2d(kernel_size=k, stride=1, padding=k // 2)

    def forward(self, x):
        x = self.cv1(x)
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')  # suppress torch 1.9.0 max_pool2d() warning
            y1 = self.m(x)
            y2 = self.m(y1)
            return self.cv2(torch.cat([x, y1, y2, self.m(y2)], 1))


Copy and paste it directly into the common.py file.
Tips: Put import warnings on it!

Error building SqlSession. ### Cause: org.apache.ibatis.builder.BuilderException: Error creating d

Debug:
I reported this error when I was a beginner of mybatis

Error building SqlSession.

Cause: org.apache.ibatis.builder.BuilderException: Error creating do

Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 6; Processing instruction targets matching ‘[XX] [mm] [ll]’ are not allowed.

Finally, it is found that one line is left blank at the beginning of the SQL mapping file, but it is required that one line cannot be left blank. Just remove the blank line

Python: How to Solve mysqlclient Install Error in Mac

It’s finally solved after many hardships. Please refer to the notes of Niu Ren and record it

Install brew

First, install brew and Baidu. There are many tutorials

Install MySQL

#Install
brew install mysql

#Configure environment variables
echo'export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile

#Make environment variables take effect
source ~/.bash_profile

#Start mysql service through script
mysql.server start

#Start mysql and set to boot
brew services start mysql

#Initialization, set password
mysql_secure_installation

ya..... bin% mysql_secure_installation
Enter password:

Securing the MySQL server deployment.


VALIDATE PASSWORD PLUGIN can be used to test passwords //Password verification plug-in, in order to improve security, you need to verify the password
and improve security. It checks the strength of password // It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin? //Prompt to install the password verification plugin

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy: //Three levels of password validation policy

LOW Length >= 8 //The minimum length is greater than or equal to 8 characters
MEDIUM Length >= 8, numeric, mixed case, and special characters //Numbers, letters, and special characters are mixed, the specific ones should be at least 1 number, 1 letter, 1 special character, and the length should not exceed 32 characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file // The most stringent, plus, the dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 //Here I choose 2 MEDIUM
Using existing password for root.

Estimated strength of the password: 50 //Here is also the rating of password strength
Change the password for root ?((Press y|Y for Yes, any other key for No): y

New password: //Password

Re-enter new password:

Estimated strength of the password: 50
Do you wish to continue with the password provided? (Press y|Y for Yes, any other key for No): y //Prompt to use the password you just entered?
 ... Failed! Error: Your password does not satisfy the current policy requirements

New password: //Password

Re-enter new password:

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No): y
By default, a MySQL installation has an anonymous user, //By default, MySQL has an anonymous user,
allowing anyone to log into MySQL without having to have //This anonymous user does not have to be created for them by a user. An anonymous user allows anyone to log into MySQL,
a user account created for them. This is intended only for //This is just to facilitate test use
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production //When using in a formal environment, it is recommended that you remove them
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No): y //Prompt to remove anonymous users
Success.

Normally, root should only be allowed to connect from //Under normal circumstances, root users are only allowed to log in using "localhost",
'localhost'. This ensures that someone cannot guess at // to ensure that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No): n //

 ... skipping.
By default, MySQL comes with a database named'test' that //By default, there is a test library in the MySQL database that can be accessed by any user.
anyone can access. This is also intended only for testing, //This is also intended only for testing
and should be removed before moving into a production // in a formal environment, should be removed
environment.

Remove test database and access to it?(Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes                       //Refresh the permission table to ensure that all modifications can take effect immediately
made so far will take effect immediately.

Reload privilege tables now?(Press y|Y for Yes, any other key for No) : y
Success.

All done! 

Install mysql-connector-c

brew install mysql-connector-c

Installing Xcode-

xcode-select --install

Install OpenSSL

brew install openssl

After installation, the terminal will display the method of configuring environment variables

If you need to have openssl@3 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/openssl@3/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@3 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"

Unlink MySQL and the linked MySQL connector mysql-connector-c

brew unlink mysql
brew link --overwrite mysql-connector-c

As shown in the figure, mysql-connector-c has a warning
warning: MySQL client is keg only and must be linked with -- force.
execute
brew link -- overwrite mysql-connector-c -- force

Install mysqlclient

Using PIP install mysqlclient will not cause any errors

Connect MySQL again

Do the opposite of unlinking MySQL and the linked MySQL connector mysql-connector-c:

brew unlink mysql-connector-c
brew link --overwrite mysql --force

[Solved] ngrok 1.7 Build Error: remote error: tls: bad certificate

Ngrok 1.7 build error

The ngrok server has been rebuilt recently. Refer to: https://zhuanlan.zhihu.com/p/33794707
Since the version of ngrok V1 has not been maintained for a long time, after compilation, the server encountered an error at startup: Remote Error: TLS: bad certificate

after searching the Internet for a long time, some people said it was the problem of the golang version, After reducing the version of golang from 1.17 to 1.9, it is still not solved. I accidentally found the log prompt x509 on the client: certificate is valid for XXX, not ngrokd.ngrok.com. I found that it may be the problem of the certificate domain name.

After searching the source code, I found that the default domain name address is ngrokd.ngrok.com, so I found a solution,
find the client source code and change the configuration. The file is:

vim ./src/ngrok/client/model.go

The defaultserveraddr in line 24 is changed to its own server domain name and port

When recompiling the self signed certificate, the domain name of the certificate must exactly match the default address here, otherwise an error will be reported.

How to Solve Python Pandas Read or Import Files Error

1. File not found

Error: [Errno 2] No such file or directory: 'C:\\Users\\ssw0926\\Desktop.chengji.csv'

1. Wrong file path

Methods to avoid errors: do not manually enter the file address, select copy.

Select the file to be read, press shift and right mouse button, and copy file address will appear.

2. Remember to add the escape character R

For example:

df=pd.read_csv(r”C:\Users\ssw0926\Desktop\chengji.csv”,encoding=”utf-8″)

2. When the file contains Chinese, it is easy to have character coding problems.

1. Error message:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid continuation byte

Solution: try to transform encoding. For example, change encoding = “UTF-8” to encoding = “GB2312” or other codes.

[Solved] SHELL Run Error: “-BASH: ./TEST.SH: /BIN/BASH^M: BAD INTERPRETER: NO SUCH FILE OR DIRECTORY”

Solve the error reported by the running shell

-bash: ./test.sh: /bin/bash^M: bad interpreter: No such file or directory

What is the reason? There is reason to suspect that it is a file format problem? We use VIM test.sh to enter the test.sh file, and then execute it in the bottom mode: set FF to check. The result shows that fileformat = DOS. Look, it is indeed a file format problem. How to solve it?

Solution:

[root@admin .sh]# vim test.sh

Execute: e + + FF = UNIX%, then delete the ^ m symbol
save and exit

or:

[root@admin .sh]# sed -i "s/\r//" test.sh

Or:

[root@admin .sh]# dos2unix test.sh

Or: VIM test.sh open the file, execute: set FF = UNIX, set the file to UNIX, then execute: WQ, and save it in UNIX format.