Category Archives: Python

Pyinstaller Error: INTEL MKL ERROR: The specified module could not be found. mkl_intel_thread.1.dll.Intel MKL FATAL ERROR: Cannot

After using pyinstaller to package successfully, an error is reported when executing the executable file

Intel MKL error: the specified module could not be found. mkl_ intel_ thread.1.dll.
Intel MKL FATAL ERROR: Cannot load mkl_ intel_ thread.1.dll.
Method 1:

Enter the directory under CONDA

./conda/Liabary/bin/

After entering the directory, find mkl_ intel_ thread.1.dll   File, add the path to the system environment variable.

However, this method does not solve my problem, so it will MKL_ intel_ The thread.1.dll file is copied to the successfully packaged directory and placed in the folder of the executable file.

Problem-solving.

[Solved] YOLOv4 Error: Layer before convolutional layer must output image.: No error

 

Recently, when learning yolo4 and running your own data set with yolo4, I found that the
training set layer before revolutionary layer must output image.: no error.

 

1. Solution

Check the customized cfg file. The size of the input image is set as follows

if both height and width are set to a multiple of 32, this problem will not occur. I set it here as 416, 416

2. Follow up questions

Pay attention to setting size to the size of the picture in your dataset, otherwise, you may not be able to open the picture. The error is as follows

Can’t load image xxxxxxxxxxxxxxxxxx

[Solved] Pytorch Error: AttributeError: ‘Tensor‘ object has no attribute ‘backword‘

Pytorch error attribute error: ‘tensor’ object has no attribute ‘backword’

According to the error description, there is no backword attribute.

error code

loss.backword() # Reverse Propagation

correct

loss.backward() # Reverse Propagation

I mistyped a a letter. There is no error prompt on the Jupiter notebook editor, which is difficult to find 😂

[Solved] AttributeError: module ‘selenium.webdriver‘ has no attribute ‘Chrome‘

**

Attributeerror: module ‘selenium. Webdriver’ has no attribute ‘chrome’

**
Description:
there is no problem creating a Google browser directly in the IDE
this error is reported when you go to Python
this is a novice problem

solution:
the reason for the error is that the selenium module is not installed in Python
this module is added in the setting project interpreter

in addition:
if it has been preceded, But not now
the possible reason is that you have opened a new project, which needs to be imported again

[Solved] AttributeError: Manager isn‘t available; ‘auth.User‘ has been swapped for ‘

AttributeError: Manager isn't available; ' auth.User' has been swapped for 'account.UserInfo'

This is because I have extended Django’s user authentication model

#setting.py
AUTH_USER_MODEL = 'account.UserInfo'

Official documents

from django.contrib.auth.models import User
from django.contrib.auth import get_user_model

User = get_user_model()

Or use the user info model directly

""" get_user_model"""
def get_user_model():
    """
    Return the User model that is active in this project.
    """
    try:
        return django_apps.get_model(settings.AUTH_USER_MODEL, require_ready=False)
    except ValueError:
        raise ImproperlyConfigured("AUTH_USER_MODEL must be of the form 'app_label.model_name'")
    except LookupError:
        raise ImproperlyConfigured(
            "AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL
        )

Invalid python sd, Fatal Python error: init_fs_encoding: failed to get the Python cod [How to Solve]

Error:
prompt when opening pycharm: invalid python sdk.
The cmd appears as: Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding;
Error message:
Python path configuration:
PYTHONHOME = ‘C:\PythonHome’
PYTHONPATH = ‘C:\PythonPath’
program name = ‘D:\Python38\python.exe’
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = ‘D:\Python38\python.exe’
sys.base_prefix = ‘C:\PythonHome’
sys.base_exec_prefix = ‘C:\PythonHome’
sys.executable = ‘D:\Python38\python.exe’
sys.prefix = ‘C:\PythonHome’
sys.exec_prefix = ‘C:\PythonHome’
sys.path = [
‘C:\PythonPath’,
‘D:\Python38\python38.zip’,
‘C:\PythonHome\DLLs’,
‘C:\PythonHome\lib’,
‘D:\Python38’,
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named ‘encodings’
Current thread 0x00008bd8 (most recent call first):

Configuring environment variables, no matter how they are configured, does not work.

Solution:
Tried opening the installation package directly and reinstalling it, and making changes in System Applications and Features, but none of them solved it.
I can only find python in settings-applications and features, uninstall it first, and then reinstall it.
The problem is solved, although after re-entering pycharm, the previous library needs to be reinstalled.

Python installs virtualenv through PIP and always reports an error: response.py“, line 438, in _error_catcher yield

G:\ESP32\esp-idf-release-v4.3>pip install virtualenv
Collecting virtualenv
  Downloading virtualenv-20.7.2-py2.py3-none-any.whl (5.3 MB)
     |█                               | 174 kB 4.5 kB/s eta 0:18:56ERROR: Exception:
Traceback (most recent call last):
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcher
    yield
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\http\client.py", line 459, in read
    n = self.readinto(b)
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\http\client.py", line 503, in readinto
    n = self.fp.readinto(b)
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\cli\base_command.py", line 173, in _main
    status = self.run(options, args)
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\cli\req_command.py", line 203, in wrapper
    return func(self, options, args)
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\commands\install.py", line 315, in run
    requirement_set = resolver.resolve(
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 94, in resolve
    result = self._result = resolver.resolve(
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 472, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 341, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 172, in _add_to_criteria
    if not criterion.candidates:
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 151, in __bool__
    return bool(self._sequence)
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 140, in __bool__
    return any(self)
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 128, in <genexpr>
    return (c for c in iterator if id(c) not in self._incompatible_ids)
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 32, in _iter_built
    candidate = func()
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 204, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 295, in __init__
    super().__init__(
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 156, in __init__
    self.dist = self._prepare()
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 227, in _prepare
    dist = self._prepare_distribution()
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 305, in _prepare_distribution
    return self._factory.preparer.prepare_linked_requirement(
  File "g:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\operations\prepare.py", line 508, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel

Later, add the path of Python to the system variable

Error in installing Python 3.6.8 for MacBook pyenv [Solved]

Solution:

1.install   Pyenv and pyenv virtualenv

brew install pyenv
git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv

Error in pyenv installation of Python 3.6.8


    else if(0 == _NSGetExecutablePath(execpath, &nsexeclength) && execpath[0] == SEP) {
                                                ^~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach-o/dyld.h:98:54: note: passing argument to parameter 'bufsize' here
extern int _NSGetExecutablePath(char* buf, uint32_t* bufsize)                 __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0);
                                                     ^
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include   -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include   -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes   -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/[email protected]/include -I/Users/guangcui/.pyenv/versions/3.6.8/include  -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/[email protected]/include -I/Users/guangcui/.pyenv/versions/3.6.8/include   -DPy_BUILD_CORE  -c ./Modules/posixmodule.c -o Modules/posixmodule.o
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include   -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include   -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes   -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/[email protected]/include -I/Users/guangcui/.pyenv/versions/3.6.8/include  -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/[email protected]/include -I/Users/guangcui/.pyenv/versions/3.6.8/include   -DPy_BUILD_CORE  -c ./Modules/errnomodule.c -o Modules/errnomodule.o
./Modules/posixmodule.c:8210:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        ret = sendfile(in, out, offset, &sbytes, &sf, flags);
              ^
./Modules/posixmodule.c:10432:5: warning: code will never be executed [-Wunreachable-code]
    Py_FatalError("abort() called from Python code didn't abort!");
    ^~~~~~~~~~~~~

 

processing method

1. Reinstall zlib bzip2

brew reinstall zlib bzip2

2. Based on the shell used, you can update . Zshrc or . Bashrc (if there is no such text, you can suggest the file in the ~ directory, enter the following content, save and restart the shell)

export PATH="$HOME/.pyenv/bin:$PATH"
export PATH="/usr/local/bin:$PATH"

eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
export LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/bzip2/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include -I/usr/local/opt/bzip2/include"

3. Enter the following installation command. If you need to change the version, you can change 3.6.8 to another version

CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.6.8 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)

[Solved] Python Error: IndentationError: expected an indented block

python Error: IndentationError: expected an indented block

        1. Error I in using the for in statement:

      ndentationError: expected an indented block

Indentation error: Expect an indented block
    1. and the error is print (I) in the second line

    1. To solve this bug, you need to add a space in front of the wrong logic code


    1. </ OL>

 

Pychart: How to Solve myspyder.items import myitem Error

Problem description

In items. Py , customize the item method.

# Define here the models for your scraped items
#
# See documentation in:
# https://docs.scrapy.org/en/latest/topics/items.html

import scrapy

class MyspiderItem(scrapy.Item):
    # define the fields for your item here like:
    name = scrapy.Field()
    title = scrapy.Field()
    desc = scrapy.Field()
    RD_achievements = scrapy.Field()

We need to introduce this method into the sweep, which is the item method defined by ourselves in the sweep, but we need to reference it in the spider in the sweep, so we need to add a string of code to change our introduction method.

Error reported in pychart from myspyder.items import itcastitem :

Original import method:

import scrapy
from crawlAdvanced.myspider.myspider.items import MyspiderItem
"""
 scrapy crawl itcast --nolog
"""

from crawlAdvanced.myspider.myspider.items import MyspiderItem ModuleNotFoundError: No module named 'crawlAdvanced'

Solution 1

Change from myspider.items import myitem to from.. items import myitem

In a package, peers use . and parents use ..

Maybe the computer doesn’t know which file you’re talking about. After all, the two file names are the same( I don’t understand. I hope the boss can correct it!)

scrapy startproject mySpider

scrapy crawl mySpider

scrapy crawl mySpider -o teachers.json

Solution 2

If the error is still reported, you can refer to the following methods: (my error is solved by using the above method)

# -*- coding: utf-8 -*-
 
#The original python method of introducing scrapy class is wrong, please reintroduce it with this method
from __future__ import absolute_import
# is the above code
 
import scrapy
 
from selenium import webdriver
from  scrapy_splash import SplashMiddleware
from scrapy_splash import SplashRequest
import pymysql
from ..item360 import Jc360Item