Author Archives: Robins

[Solved] python3.7+django2.2 Error: AttributeError: ‘str’ object has no attribute ‘decode’

Environment: python3.7+django2.2
Error message:
AttributeError: ‘str’ object has no attribute ‘decode’

Solution:
Find the django file under the python file>db file>backends>mysql>operations.py
open a file:
Ctrl+f search query.decode after opening

 

Then change query.decode to query.encode
#Original code:

query = getattr(cursor, '_executed', None)
if query is not None:
query = query.decode(errors='replace')
return query

#change into:

query = getattr(cursor, '_executed', None)
if query is not None:
query = query.encode(errors='replace')
return query

Done!

[Solved] Java EE file upload Error: web.xml error

Javaee file upload
Web.xml error
The error content is as follows:

cvc-id.3: A field of identity constraint ‘web-common-servlet-name-uniqueness’ matched element ‘web-app’, but this element
does not have a simple type.

Solution:

xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee
Change the ‘java’ to uppercase

[Solved] ElasticSearch Error: FORBIDDEN/12/index read-only/allow delete (api) ,read_only_allow_delete Set windows

Elasticsearch reports an error. For bind/12/index read only/allow delete (API)
this error is because the indexes in elasticsearch are read-only and cannot be added or modified. Query the official website. The reason for this problem may be that the storage disk where es is located does not have enough space, which causes es to automatically turn on data protection and limit it to read-only
just execute the following command. If curl is not installed in the window, please install curl first

Note: when executing the following commands in Windows system, because the single quotation mark “‘” cannot be recognized, please modify it to double quotation mark and or escape the double quotation mark

The windows system executes the following commands:

curl -XPUT -H "Content-Type: application/json" http://127.0.0.1:9200/_all/_settings -d "{\"index.blocks.read_only_allow_delete\": null}"

the Linux system executes the following command:

curl -XPUT -H "Content-Type: application/json" http://127.0.0.1:9200/_all/_settings -d '{"index.blocks.read_only_allo

[Solved] idea Start Project Error: idea Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.

Question:

After the company takes a new MAC system notebook and installs idea, start the code on GitHub and report the following exception: idea error: could not create the Java virtual machine Error: A fatal exception has occurred. Program will exit.

Find out the reason later. It turns out that the newly installed version of idea is too new, and the default JDK version of idea is inconsistent with the JDK version installed by the operating system. Finally, modify the JDK version of idea to keep up with the operating system. It’s OK.

Solution: enter the CMD window and enter Java – version to view the current JDK version and idea –> File–> Project Structure–> Project Settings–> Project view the JDK version used by the current project

[Solved] kuberlet Service Startup Error: “Failed to run kubelet” err=”failed to run Kubelet: misconfiguration: kubelet cgroup driver: \”systemd\” is different from docker cgroup driver: \”cgroupfs\””

After analysis, it is found that “kebernetes sets the CGroup driver to SYSTEMd by default, while the CGroup driver of docker service is cgroups”. There are two solutions. First, why is the service configuration file of docker the same as that of kubernetes? Second, modify the configuration file of kebernetes to cgroups. The first one is adopted here.

Modify the configuration file of docker service,/etc/docker/daemon.JSON, and add the following

"exec-opts": ["native.cgroupdriver=systemd"]

Restart dokcer service:

sudo systemctl daemon-reload
sudo systemctl restart docker

Restart kuberlet:

systemctl restart kubelet

mysqldump Backup Error: mysqldump: Got error: 1449: The user specified as a definer (‘xxx’@’%’) does not exist when using LOCK TABLES

1. Find XXX user and find that it does not exist

select user,host from mysql. user;

The XXX user who created the view before has been deleted

2. Find these views and modify the definer information

select concat(“alter_definer=`root`@`%` view “, table_name, ” as “, view_definition, “;”)
from information_ schema. views
where table_schema='< Your database name> ‘;

The above SQL will generate a statement to modify the definer, which can be executed

[Solved] EasyCVR Error: LibEasySnap.dll:The specified module could not be found

Easycvr is a video protocol fusion platform developed by tsingsee Qingxi video. In addition to accessing RTSP and gb28181, easycvr also completes docking with equipment and video stream transmission through private protocols such as hiksdk and EHOME.

Sometimes we encounter that easycvr cannot be started and the error libeasysnap DLL: the specified module could not be found. Generally, if the service fails to start, it will be in the log, so we check the log to see if there is any error message:

You can see that the reason for the error is that the file is missing. Therefore, we need to check whether libeasysnap is missing in the easycvr directory dll:

Libeasysnap. Is found in the directory DLL, but still prompt that the DLL file is missing.

After investigation, it is found that only the individual system environment (windowsserver2012 RC) is missing from this DLL. Therefore, we need to copy all DLL files beginning with AV in the directory of other versions to the directory of the current version, and it will be normal to start again.

[Solved] JSTL1.2 Error: org.apache.catalina.core.StandardWrapperValve.invoke…

Problem description

An error is reported after importing the required dependencies and referencing the following core tag library. JSTL cannot be used.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


Reason:

The dependency jar package is missing in the Tomcat project.

jstl 1.1 jstl 1.2
依赖 jar 包 standard.jar taglibs-standard-impl-1.2.5.jar
taglibs-standard-spec-1.2.5.jar

solution
Option 1: Add these two dependencies

<!-- https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard-spec -->
<dependency>
  <groupId>org.apache.taglibs</groupId>
  <artifactId>taglibs-standard-spec</artifactId>
  <version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard-impl -->
<dependency>
  <groupId>org.apache.taglibs</groupId>
  <artifactId>taglibs-standard-impl</artifactId>
  <version>1.2.5</version>
  <scope>runtime</scope>
</dependency>

Solution 2: manually import the jar package

you can find these two jar packages in the Tomcat \ webapps \ examples \ WEB-INF \ lib directory, and then copy them to the Lib directory of Tomcat or the Lib directory of the project to solve the problem</ font>

1. Copy to the Lib directory of Tomcat (once and for all)

2. Copy to the Lib directory of the project (only valid for this project)

About importing external jar packages in the project, you can see importing external jar packages in eclipse and idea

[Solved] Python: third-party library fire Install Error

1. Linux Environment

report errors

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting fire
  Downloading https://mirrors.aliyun.com/pypi/packages/11/07/a119a1aa04d37bc819940d95ed7e135a7dcca1c098123a3764a6dcace9e7/fire-0.4.0.tar.gz (87 kB)
     |????????????????????????????????| 87 kB 3.8 MB/s 
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-6x44h_/fire/setup.py'"'"'; __file__='"'"'/tmp/pip-install-6x44h_/fire/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-szF2KD
         cwd: /tmp/pip-install-6x44h_/fire/
    Complete output (1 lines):
    error in fire setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Solution:

This problem is mainly because the version of setuptools is too low, so you only need to upgrade the software. Install fire after upgrading the version of setuptools

]# pip install setuptools -U
]# pip install fire

2. Windows Environment

report errors

(env) Lenovo@Lenovo python> pip install fire
Traceback (most recent call last):
  File "D:\Python27\Lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "D:\Python27\Lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "F:\workspace\cli\python\env\Scripts\pip.exe\__main__.py", line 4, in <module>
  File "f:\workspace\cli\python\env\lib\site-packages\pip\_internal\cli\main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "f:\workspace\cli\python\env\lib\site-packages\pip\_internal\cli\autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "f:\workspace\cli\python\env\lib\site-packages\pip\_internal\cli\main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "f:\workspace\cli\python\env\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 25, in <module>
    from pip._internal.cli.progress_bars import BAR_TYPES
    _BaseBar = _select_progress_class(IncrementalBar, Bar)  # type: Any
  File "f:\workspace\cli\python\env\lib\site-packages\pip\_internal\cli\progress_bars.py", line 48, in _select_progress_class
    six.text_type().join(characters).encode(encoding)
LookupError: unknown encoding: cp65001

Solution

This problem is mainly caused by the character encoding on the command line. Some characters cannot be used normally. Just modify the default character encoding. If you continue to report errors, you can modify it to other character codes

(env) Lenovo@Lenovo python> chcp 1252 //Modify to 1252 (ANSI)
(env) Lenovo@Lenovo python> pip install fire

 

cURL error 1014: SSL verify failed Error [How to Solve]

report errors

[ERROR] cURL error 1014: SSL verify failed (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://mgobe.tencentcloudapi.com/[247] in /www/wwwroot/*.net/vendor/
[ERROR] #0 /www/wwwroot/tencentgame.net/vendor/tencentcloud/tencentcloud-sdk-php/src/TencentCloud/Common/AbstractClient.php(175): TencentCloud\Common\AbstractClient->doRequestWithOptions()
#1 /www/wwwroot/*.net/app/Controller/IndexController.php(46): TencentCloud\Common\AbstractClient->__call()
#2 /www/wwwroot/*.net/vendor/hyperf/http-server/src/CoreMiddleware.php(161): App\Controller\IndexController->index()
#3 /www/wwwroot/*.net/vendor/hyperf/http-server/src/CoreMiddleware.php(113): Hyperf\HttpServer\CoreMiddleware->handleFound()

frame

hyperf swoole 4.5. 9 openssl1. one point one

direction

1. System layer. The OpenSSL version of swoole is too low. PHP — RI swoole view OpenSSL version is 1.0 1. The system checks that the OpenSSL version is 1.1 1 upgrade the OpenSSL version of swoole. Recompile (not working)

2. Framework issues

The hyperf framework spoole adopts the co process mode, and guzzle will cause blocking and error reporting

use GuzzleHttp\Client;
use Hyperf\Guzzle\CoroutineHandler;
use GuzzleHttp\HandlerStack;

$client = new Client([
    'base_uri' => 'http://127.0.0.1:8080',
    'handler' => HandlerStack::create(new CoroutineHandler()),
    'timeout' => 5,
    'swoole' => [
        'timeout' => 10,
        'socket_buffer_size' => 1024 * 1024 * 2,
    ],
]);

$response = $client->get('/');

1. Add handler at the request => Handlerstack:: create (New coroutinehandler()) to solve the problem

2. Directly use hyperf\ guzzle\coroutinehandler as the processor and set it in the guzzle client to turn it into collaborative operation. In order to facilitate the creation of guzzle objects for collaborative processes, we provide a factory class hyperf\guzzle\clientfactory to facilitate the creation of clients

<?php 
use Hyperf\Guzzle\ClientFactory;

class Foo {
    /**
     * @var \Hyperf\Guzzle\ClientFactory
     */
    private $clientFactory;
    
    public function __construct(ClientFactory $clientFactory)
    {
        $this->clientFactory = $clientFactory;
    }
    
    public function bar()
    {
        // $options is equivalent to the $config parameter of the GuzzleHttp\Client constructor
         $options = [];
         // $client is a coroutineized GuzzleHttp\Client object
        $client = $this->clientFactory->create($options);
    }
}