Tag Archives: python

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

Syntax Error: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position resolution

Error reporting: syntax error: (Unicode error) ‘Unicode scape’ codec can’t decode bytes in position 2-3: tr

For example, in the file, the file path I passed in is like this

sys.path.append('c:\Users\mshacxiang\VScode_ project\web_ ddt')

Cause analysis: the file path can be read in the windows system, but \ has escape meaning in the Python string. For example, \ t can represent tab and \ n represents line feed. Therefore, we need to take some measures to prevent \ from being interpreted as escape characters. Add r before the path to keep the original value of the character. This solves the problem

sys.path.append(r'c:\Users\mshacxiang\VScode_ project\web_ ddt')

Module not found:Error:Can’t resolve ‘rc-animate/lib/CSSMotionList’ in ‘……’

explain

After the react project is compiled, sometimes the following error will be reported if you enter cnpm start

Add the following code to the package.json file to specify the version

"resolutions": {
  "css-animation": "1.5.0",
  "rc-animate": "2.8.2"
},

 

Add the following configuration in dependencies

"css-animation": "1.5.0",
"rc-animate": "2.8.2",

Maskrcnn-benchmark Error: KeyError “Non-existent config key: MODEL.BACKBONE.OUT_CHANNELS“

When trying to extract visual features using VQA maskrcnn benchmark: files · master · vedanuj Goswami/VQA maskrcnn benchmark · gitlab,

After compiling maskrcnn benchmark according to the instructions of install, run

python script/extract_features.py ... 

An error occurred:

KeyError "Non-existent config key: MODEL.BACKBONE.OUT_CHANNELS"

The problem is: instead of compiling maskrcnn benchmark, you can compile setup.py under VQA maskrcnn benchmark

PS: the author has made corresponding fine adjustments to the network structure and code. The structure in the original maskrcnn library does not correspond to config

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

Httprunner Run Error: while parsing a block mapping

When I first came into contact with httprunner, I was not familiar with the YML format. After running the use case, I reported an error while parsing a block mapping
an error is reported as shown in the figure:

after checking the data, it is said that there is no alignment. It is recommended to use space alignment. Then find my 9 lines, find that the number of spaces is different from the others, and then use spaces to keep consistent with the others.

For example, in my extract, I counted the four spaces before the request, counted the first four spaces before the extract, and found that they were not four. After changing them, I succeeded. PS: because the number of extracted spaces in the front is wrong, and the spaces of imagetoken below are also wrong. They will succeed after they are changed together