Category Archives: Python

Gunicorn Flask Error: [ERROR] Socket error processing request

gunicorn、flask error: [ERROR] Socket error processing request, The detailed error message is as follows.
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/gunicorn/workers/base_async.py”, line 65, in handle
util.reraise(*sys.exc_info())
File “/usr/local/lib/python3.6/site-packages/gunicorn/util.py”, line 625, in reraise
raise value
File “/usr/local/lib/python3.6/site-packages/gunicorn/workers/base_async.py”, line 48, in handle
req = next(parser)
File “/usr/local/lib/python3.6/site-packages/gunicorn/http/parser.py”, line 41, in __next__
self.mesg = self.mesg_class(self.cfg, self.unreader, self.req_count)
File “/usr/local/lib/python3.6/site-packages/gunicorn/http/message.py”, line 186, in __init__
super().__init__(cfg, unreader)
File “/usr/local/lib/python3.6/site-packages/gunicorn/http/message.py”, line 53, in __init__
unused = self.parse(self.unreader)
File “/usr/local/lib/python3.6/site-packages/gunicorn/http/message.py”, line 198, in parse
self.get_data(unreader, buf, stop=True)
File “/usr/local/lib/python3.6/site-packages/gunicorn/http/message.py”, line 189, in get_data
data = unreader.read()
File “/usr/local/lib/python3.6/site-packages/gunicorn/http/unreader.py”, line 37, in read
d = self.chunk()
File “/usr/local/lib/python3.6/site-packages/gunicorn/http/unreader.py”, line 64, in chunk
return self.sock.recv(self.mxchunk)
File “/usr/local/lib64/python3.6/site-packages/gevent/_ssl3.py”, line 555, in recv
return self.read(buflen)
File “/usr/local/lib64/python3.6/site-packages/gevent/_ssl3.py”, line 386, in read
return self._sslobj.read(nbytes or 1024)
File “/usr/lib64/python3.6/ssl.py”, line 589, in read
v = self._sslobj.read(len)
OSError: [Errno 0] Error
Solution.
gunicorn cannot support both http and https requests

I have changed from gunicorn to uwsgi and no more headaches!!!
Link:
https://stackoverflow.com/questions/51619559/socket-error-processing-request-with-flask-gunicorn-docker-and-azure

How to Solve RuntimeError: cuDNN error: CUDNN_STATUS_EXECUTION_FAILED

Case 1: the versions of CUDA, cudnn, Python and python do not match. Note that the python version, in particular, is easy to ignore.

Case 2 (my case is this): under the condition of case 1, check whether the graphics card used by your program is full, and if it is full, replace the unused card(‘ cuda:3 ’ —> ‘ cuda:0 ’)。

Case 3: add
torch. Backends. Cudnn. Enabled = false in the code

httpd Run Error: Job for httpd.service failed because the control process exited with error code.

Job for httpd.service failed because the control process exited with error code.
See “systemctl status httpd.service” and “journalctl -xe” for details.

When opening the httpd service, the error as shown in the title appears

 

# systemctl start httpd.service

Job for httpd.service failed because the control process exited with error code.
See "systemctl status httpd.service" and "journalctl -xe" for details.

View the startup log through systemctl status

Check whether port 80 is occupied

netstat -antlp | grep 80

Killing process with kill instruction

Input the httpd start command again, and the error still exists.

Finally, it is found that the & lt; Directory/> It is found that the access permission of the/usr directory is readable by anyone but not executable. Therefore, the access permission of the/usr directory is changed

chmod -R o+x /usr

Try to open the service again, success!

to update:

Configuration of httpd.conf

cffi Security Report “c / _cffi_backend.oc / _cffi_backend.c: 15:17: error: ffi.h: No such file or directory” Problem

Cffi installation problem
Environment: powerlinux6.5-64
installation:
1. Unzip cffi-1.11.5.tar.gz
2. Enter the cffi directory

   cd cffi-1.11.5
   python setup.py install
    error message is as follows:
[root@localhost cffi-1.11.5]# /opt/python-powerlinux6-64/bin/python setup.py install
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
'''
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
running install
running bdist_egg
running egg_info
writing requirements to cffi.egg-info/requires.txt
writing cffi.egg-info/PKG-INFO
writing top-level names to cffi.egg-info/top_level.txt
writing dependency_links to cffi.egg-info/dependency_links.txt
writing entry points to cffi.egg-info/entry_points.txt
reading manifest file 'cffi.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'cffi.egg-info/SOURCES.txt
installing library code to build/bdist.linux-ppc64/egg
running install_lib
running build_py
running build_ext
building '_cffi_backend' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/includ
e/libffi -I/opt/python-powerlinux6-64/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-ppc64-2.7/c/_cffi_backend.oc/_cffi_backend.c:15:17: error: ffi.h: No such file or directory
In file included from c/_cffi_backend.c:92:
c/malloc_closure.h:81: error: expected specifier-qualifier-list before ‘ffi_closure’
c/malloc_closure.h: In function ‘more_core’:
c/malloc_closure.h:117: warning: division by zero
c/malloc_closure.h:149: error: ‘union mmaped_block’ has no member named ‘next’
c/malloc_closure.h: At top level:

As you can see from the tips:
Perhaps you should add the directory containing ‘libffi. PC’
to the PKG_CONFIG_PATH environment variable
Package libffi was not found in the pkg-config search path. Find the directory for libffi.pc,

#### libffi is not installed
Install libffi to compile and install.

[root@localhost cffi-1.11.5]# export PKG_CONFIG_PATH=/opt/python-powerlinux6-64/lib/pkgconfig/

is found by compiling python/lib64

command ‘gcc’ failed with exit status 1 error while installing scrapy

When I tried to install Scrapy I got this error:

    warning: no previously-included files found matching '*.py'
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in /usr/local/lib/python2.7/site-packages/pyOpenSSL-0.14-py2.7.egg (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.9 in /usr/local/lib/python2.7/site-packages/cssselect-0.9.1-py2.7.egg (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in /usr/local/lib/python2.7/site-packages/six-1.6.1-py2.7.egg (from Scrapy)
Downloading/unpacking zope.interface>=3.6.0 (from Twisted>=10.0.0->Scrapy)
  Downloading zope.interface-4.1.1.tar.gz (864kB): 864kB downloaded
  Running setup.py (path:/tmp/pip_build_root/zope.interface/setup.py) egg_info for package zope.interface

    warning: no previously-included files matching '*.dll' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.pyo' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
Downloading/unpacking cryptography>=0.2.1 (from pyOpenSSL->Scrapy)
  Downloading cryptography-0.4.tar.gz (260kB): 260kB downloaded
  Running setup.py (path:/tmp/pip_build_root/cryptography/setup.py) egg_info for package cryptography
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    c/_cffi_backend.c:14:17: error: ffi.h: No such file or directory
    In file included from c/_cffi_backend.c:21:
    c/malloc_closure.h:33: error: expected specifier-qualifier-list before 'ffi_closure'
    c/malloc_closure.h: In function 'more_core':
    c/malloc_closure.h:69: warning: division by zero
    c/malloc_closure.h:96: error: 'union mmaped_block' has no member named 'next'
    c/malloc_closure.h: At top level:
    c/malloc_closure.h:105: error: expected ')' before '*' token
    c/malloc_closure.h:113: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
    c/_cffi_backend.c:187: error: expected specifier-qualifier-list before 'ffi_cif'
    c/_cffi_backend.c: In function 'cdataowninggc_dealloc':
    c/_cffi_backend.c:1499: error: 'ffi_closure' undeclared (first use in this function)
    c/_cffi_backend.c:1499: error: (Each undeclared identifier is reported only once
    c/_cffi_backend.c:1499: error: for each function it appears in.)
    c/_cffi_backend.c:1499: error: 'closure' undeclared (first use in this function)
    c/_cffi_backend.c:1499: error: expected expression before ')' token
    c/_cffi_backend.c:1502: warning: implicit declaration of function 'cffi_closure_free'
    c/_cffi_backend.c: In function 'cdataowninggc_traverse':
    c/_cffi_backend.c:1514: error: 'ffi_closure' undeclared (first use in this function)
    c/_cffi_backend.c:1514: error: 'closure' undeclared (first use in this function)
    c/_cffi_backend.c:1514: error: expected expression before ')' token
    c/_cffi_backend.c: In function 'cdataowninggc_clear':
    c/_cffi_backend.c:1530: error: 'ffi_closure' undeclared (first use in this function)
    c/_cffi_backend.c:1530: error: 'closure' undeclared (first use in this function)
    c/_cffi_backend.c:1530: error: expected expression before ')' token
    c/_cffi_backend.c: In function 'cdataowning_repr':
    c/_cffi_backend.c:1654: error: 'ffi_closure' undeclared (first use in this function)
    c/_cffi_backend.c:1654: error: expected expression before ')' token
    c/_cffi_backend.c: At top level:
    c/_cffi_backend.c:2200: error: expected declaration specifiers or '...' before 'ffi_abi'
    c/_cffi_backend.c: In function 'cdata_call':
    c/_cffi_backend.c:2334: error: 'ffi_abi' undeclared (first use in this function)
    c/_cffi_backend.c:2334: error: expected ';' before 'fabi'
    c/_cffi_backend.c:2376: error: 'fabi' undeclared (first use in this function)
    c/_cffi_backend.c:2380: error: too many arguments to function 'fb_prepare_cif'
    c/_cffi_backend.c:2385: error: 'cif_description_t' has no member named 'exchange_size'
    c/_cffi_backend.c:2395: error: 'cif_description_t' has no member named 'exchange_offset_arg'
    c/_cffi_backend.c:2425: error: 'cif_description_t' has no member named 'exchange_offset_arg'
    c/_cffi_backend.c:2430: warning: implicit declaration of function 'ffi_call'
    c/_cffi_backend.c:2430: error: 'cif_description_t' has no member named 'cif'
    c/_cffi_backend.c: In function 'b_new_primitive_type':
    c/_cffi_backend.c:3334: error: 'ffi_type' undeclared (first use in this function)
    c/_cffi_backend.c:3334: error: 'ffitype' undeclared (first use in this function)
    c/_cffi_backend.c:3355: error: 'ffi_type_sint8' undeclared (first use in this function)
    c/_cffi_backend.c:3356: error: 'ffi_type_sint16' undeclared (first use in this function)
    c/_cffi_backend.c:3357: error: 'ffi_type_sint32' undeclared (first use in this function)
    c/_cffi_backend.c:3358: error: 'ffi_type_sint64' undeclared (first use in this function)
    c/_cffi_backend.c:3364: error: 'ffi_type_float' undeclared (first use in this function)
    c/_cffi_backend.c:3366: error: 'ffi_type_double' undeclared (first use in this function)
    c/_cffi_backend.c:3368: error: 'ffi_type_longdouble' undeclared (first use in this function)
    c/_cffi_backend.c:3374: error: 'ffi_type_uint8' undeclared (first use in this function)
    c/_cffi_backend.c:3375: error: 'ffi_type_uint16' undeclared (first use in this function)
    c/_cffi_backend.c:3376: error: 'ffi_type_uint32' undeclared (first use in this function)
    c/_cffi_backend.c:3377: error: 'ffi_type_uint64' undeclared (first use in this function)
    c/_cffi_backend.c: At top level:
    c/_cffi_backend.c:3931: error: expected specifier-qualifier-list before 'ffi_type'
    c/_cffi_backend.c:3950: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
    c/_cffi_backend.c: In function 'fb_build':
    c/_cffi_backend.c:4081: error: 'struct funcbuilder_s' has no member named 'atypes'
    c/_cffi_backend.c:4081: error: 'ffi_type' undeclared (first use in this function)
    c/_cffi_backend.c:4081: error: expected expression before ')' token
    c/_cffi_backend.c:4082: error: 'struct funcbuilder_s' has no member named 'nargs'
    c/_cffi_backend.c:4085: error: 'struct funcbuilder_s' has no member named 'rtype'
    c/_cffi_backend.c:4085: warning: implicit declaration of function 'fb_fill_type'
    c/_cffi_backend.c:4093: error: 'cif_description_t' has no member named 'exchange_offset_arg'
    c/_cffi_backend.c:4096: error: 'struct funcbuilder_s' has no member named 'rtype'
    c/_cffi_backend.c:4097: error: 'ffi_arg' undeclared (first use in this function)
    c/_cffi_backend.c:4107: error: 'atype' undeclared (first use in this function)
    c/_cffi_backend.c:4120: error: 'struct funcbuilder_s' has no member named 'atypes'
    c/_cffi_backend.c:4121: error: 'struct funcbuilder_s' has no member named 'atypes'
    c/_cffi_backend.c:4124: error: 'cif_description_t' has no member named 'exchange_offset_arg'
    c/_cffi_backend.c:4131: error: 'cif_description_t' has no member named 'exchange_size'
    c/_cffi_backend.c: In function 'fb_build_name':
    c/_cffi_backend.c:4153: error: 'struct funcbuilder_s' has no member named 'nargs'
    c/_cffi_backend.c:4162: error: 'struct funcbuilder_s' has no member named 'fct'
    c/_cffi_backend.c:4164: error: 'struct funcbuilder_s' has no member named 'fct'
    c/_cffi_backend.c: In function 'fb_prepare_ctype':
    c/_cffi_backend.c:4205: error: 'struct funcbuilder_s' has no member named 'fct'
    c/_cffi_backend.c:4215: error: 'struct funcbuilder_s' has no member named 'fct'
    c/_cffi_backend.c: At top level:
    c/_cffi_backend.c:4235: error: expected declaration specifiers or '...' before 'ffi_abi'
    c/_cffi_backend.c: In function 'fb_prepare_cif':
    c/_cffi_backend.c:4262: warning: implicit declaration of function 'ffi_prep_cif'
    c/_cffi_backend.c:4262: error: 'cif_description_t' has no member named 'cif'
    c/_cffi_backend.c:4262: error: 'fabi' undeclared (first use in this function)
    c/_cffi_backend.c:4262: error: 'struct funcbuilder_s' has no member named 'nargs'
    c/_cffi_backend.c:4263: error: 'struct funcbuilder_s' has no member named 'rtype'
    c/_cffi_backend.c:4263: error: 'struct funcbuilder_s' has no member named 'atypes'
    c/_cffi_backend.c:4263: error: 'FFI_OK' undeclared (first use in this function)
    c/_cffi_backend.c: In function 'b_new_function_type':
    c/_cffi_backend.c:4280: error: 'FFI_DEFAULT_ABI' undeclared (first use in this function)
    c/_cffi_backend.c:4318: error: too many arguments to function 'fb_prepare_cif'
    c/_cffi_backend.c:4326: error: 'struct funcbuilder_s' has no member named 'nargs'
    c/_cffi_backend.c:4336: error: 'struct funcbuilder_s' has no member named 'nargs'
    c/_cffi_backend.c: In function 'convert_from_object_fficallback':
    c/_cffi_backend.c:4360: error: 'ffi_arg' undeclared (first use in this function)
    c/_cffi_backend.c: At top level:
    c/_cffi_backend.c:4432: error: expected ')' before '*' token
    c/_cffi_backend.c: In function 'b_callback':
    c/_cffi_backend.c:4503: error: 'ffi_closure' undeclared (first use in this function)
    c/_cffi_backend.c:4503: error: 'closure' undeclared (first use in this function)
    c/_cffi_backend.c:4524: error: 'ffi_arg' undeclared (first use in this function)
    c/_cffi_backend.c:4542: warning: implicit declaration of function 'cffi_closure_alloc'
    c/_cffi_backend.c:4559: warning: implicit declaration of function 'ffi_prep_closure'
    c/_cffi_backend.c:4559: error: 'cif_description_t' has no member named 'cif'
    c/_cffi_backend.c:4560: error: 'invoke_callback' undeclared (first use in this function)
    c/_cffi_backend.c:4560: error: 'FFI_OK' undeclared (first use in this function)
    c/_cffi_backend.c: In function 'init_cffi_backend':
    c/_cffi_backend.c:5489: error: 'FFI_DEFAULT_ABI' undeclared (first use in this function)
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_root/cryptography/setup.py", line 174, in <module>
        "test": PyTest,
      File "/usr/local/lib/python2.7/distutils/core.py", line 112, in setup
        _setup_distribution = dist = klass(attrs)
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 260, in __init__
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 285, in fetch_build_eggs
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 631, in resolve
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 871, in best_match
      File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 883, in obtain
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 335, in fetch_build_egg
      File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 595, in easy_install
      File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 625, in install_item
      File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 822, in install_eggs
      File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 1028, in build_and_install
      File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 1016, in run_setup
    distutils.errors.DistutilsError: Setup script exited with error: command 'gcc' failed with exit status 1
    Complete output from command python setup.py egg_info:
    Package libffi was not found in the pkg-config search path.

Perhaps you should add the directory containing `libffi.pc'

to the PKG_CONFIG_PATH environment variable

No package 'libffi' found

Package libffi was not found in the pkg-config search path.

Perhaps you should add the directory containing `libffi.pc'

to the PKG_CONFIG_PATH environment variable

No package 'libffi' found

Package libffi was not found in the pkg-config search path.

Perhaps you should add the directory containing `libffi.pc'

to the PKG_CONFIG_PATH environment variable

No package 'libffi' found

Package libffi was not found in the pkg-config search path.

Perhaps you should add the directory containing `libffi.pc'

to the PKG_CONFIG_PATH environment variable

No package 'libffi' found

Package libffi was not found in the pkg-config search path.

Perhaps you should add the directory containing `libffi.pc'

to the PKG_CONFIG_PATH environment variable

No package 'libffi' found

c/_cffi_backend.c:14:17: error: ffi.h: No such file or directory

In file included from c/_cffi_backend.c:21:

c/malloc_closure.h:33: error: expected specifier-qualifier-list before 'ffi_closure'

c/malloc_closure.h: In function 'more_core':

c/malloc_closure.h:69: warning: division by zero

c/malloc_closure.h:96: error: 'union mmaped_block' has no member named 'next'

c/malloc_closure.h: At top level:

c/malloc_closure.h:105: error: expected ')' before '*' token

c/malloc_closure.h:113: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

c/_cffi_backend.c:187: error: expected specifier-qualifier-list before 'ffi_cif'

c/_cffi_backend.c: In function 'cdataowninggc_dealloc':

c/_cffi_backend.c:1499: error: 'ffi_closure' undeclared (first use in this function)

c/_cffi_backend.c:1499: error: (Each undeclared identifier is reported only once

c/_cffi_backend.c:1499: error: for each function it appears in.)

c/_cffi_backend.c:1499: error: 'closure' undeclared (first use in this function)

c/_cffi_backend.c:1499: error: expected expression before ')' token

c/_cffi_backend.c:1502: warning: implicit declaration of function 'cffi_closure_free'

c/_cffi_backend.c: In function 'cdataowninggc_traverse':

c/_cffi_backend.c:1514: error: 'ffi_closure' undeclared (first use in this function)

c/_cffi_backend.c:1514: error: 'closure' undeclared (first use in this function)

c/_cffi_backend.c:1514: error: expected expression before ')' token

c/_cffi_backend.c: In function 'cdataowninggc_clear':

c/_cffi_backend.c:1530: error: 'ffi_closure' undeclared (first use in this function)

c/_cffi_backend.c:1530: error: 'closure' undeclared (first use in this function)

c/_cffi_backend.c:1530: error: expected expression before ')' token

c/_cffi_backend.c: In function 'cdataowning_repr':

c/_cffi_backend.c:1654: error: 'ffi_closure' undeclared (first use in this function)

c/_cffi_backend.c:1654: error: expected expression before ')' token

c/_cffi_backend.c: At top level:

c/_cffi_backend.c:2200: error: expected declaration specifiers or '...' before 'ffi_abi'

c/_cffi_backend.c: In function 'cdata_call':

c/_cffi_backend.c:2334: error: 'ffi_abi' undeclared (first use in this function)

c/_cffi_backend.c:2334: error: expected ';' before 'fabi'

c/_cffi_backend.c:2376: error: 'fabi' undeclared (first use in this function)

c/_cffi_backend.c:2380: error: too many arguments to function 'fb_prepare_cif'

c/_cffi_backend.c:2385: error: 'cif_description_t' has no member named 'exchange_size'

c/_cffi_backend.c:2395: error: 'cif_description_t' has no member named 'exchange_offset_arg'

c/_cffi_backend.c:2425: error: 'cif_description_t' has no member named 'exchange_offset_arg'

c/_cffi_backend.c:2430: warning: implicit declaration of function 'ffi_call'

c/_cffi_backend.c:2430: error: 'cif_description_t' has no member named 'cif'

c/_cffi_backend.c: In function 'b_new_primitive_type':

c/_cffi_backend.c:3334: error: 'ffi_type' undeclared (first use in this function)

c/_cffi_backend.c:3334: error: 'ffitype' undeclared (first use in this function)

c/_cffi_backend.c:3355: error: 'ffi_type_sint8' undeclared (first use in this function)

c/_cffi_backend.c:3356: error: 'ffi_type_sint16' undeclared (first use in this function)

c/_cffi_backend.c:3357: error: 'ffi_type_sint32' undeclared (first use in this function)

c/_cffi_backend.c:3358: error: 'ffi_type_sint64' undeclared (first use in this function)

c/_cffi_backend.c:3364: error: 'ffi_type_float' undeclared (first use in this function)

c/_cffi_backend.c:3366: error: 'ffi_type_double' undeclared (first use in this function)

c/_cffi_backend.c:3368: error: 'ffi_type_longdouble' undeclared (first use in this function)

c/_cffi_backend.c:3374: error: 'ffi_type_uint8' undeclared (first use in this function)

c/_cffi_backend.c:3375: error: 'ffi_type_uint16' undeclared (first use in this function)

c/_cffi_backend.c:3376: error: 'ffi_type_uint32' undeclared (first use in this function)

c/_cffi_backend.c:3377: error: 'ffi_type_uint64' undeclared (first use in this function)

c/_cffi_backend.c: At top level:

c/_cffi_backend.c:3931: error: expected specifier-qualifier-list before 'ffi_type'

c/_cffi_backend.c:3950: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

c/_cffi_backend.c: In function 'fb_build':

c/_cffi_backend.c:4081: error: 'struct funcbuilder_s' has no member named 'atypes'

c/_cffi_backend.c:4081: error: 'ffi_type' undeclared (first use in this function)

c/_cffi_backend.c:4081: error: expected expression before ')' token

c/_cffi_backend.c:4082: error: 'struct funcbuilder_s' has no member named 'nargs'

c/_cffi_backend.c:4085: error: 'struct funcbuilder_s' has no member named 'rtype'

c/_cffi_backend.c:4085: warning: implicit declaration of function 'fb_fill_type'

c/_cffi_backend.c:4093: error: 'cif_description_t' has no member named 'exchange_offset_arg'

c/_cffi_backend.c:4096: error: 'struct funcbuilder_s' has no member named 'rtype'

c/_cffi_backend.c:4097: error: 'ffi_arg' undeclared (first use in this function)

c/_cffi_backend.c:4107: error: 'atype' undeclared (first use in this function)

c/_cffi_backend.c:4120: error: 'struct funcbuilder_s' has no member named 'atypes'

c/_cffi_backend.c:4121: error: 'struct funcbuilder_s' has no member named 'atypes'

c/_cffi_backend.c:4124: error: 'cif_description_t' has no member named 'exchange_offset_arg'

c/_cffi_backend.c:4131: error: 'cif_description_t' has no member named 'exchange_size'

c/_cffi_backend.c: In function 'fb_build_name':

c/_cffi_backend.c:4153: error: 'struct funcbuilder_s' has no member named 'nargs'

c/_cffi_backend.c:4162: error: 'struct funcbuilder_s' has no member named 'fct'

c/_cffi_backend.c:4164: error: 'struct funcbuilder_s' has no member named 'fct'

c/_cffi_backend.c: In function 'fb_prepare_ctype':

c/_cffi_backend.c:4205: error: 'struct funcbuilder_s' has no member named 'fct'

c/_cffi_backend.c:4215: error: 'struct funcbuilder_s' has no member named 'fct'

c/_cffi_backend.c: At top level:

c/_cffi_backend.c:4235: error: expected declaration specifiers or '...' before 'ffi_abi'

c/_cffi_backend.c: In function 'fb_prepare_cif':

c/_cffi_backend.c:4262: warning: implicit declaration of function 'ffi_prep_cif'

c/_cffi_backend.c:4262: error: 'cif_description_t' has no member named 'cif'

c/_cffi_backend.c:4262: error: 'fabi' undeclared (first use in this function)

c/_cffi_backend.c:4262: error: 'struct funcbuilder_s' has no member named 'nargs'

c/_cffi_backend.c:4263: error: 'struct funcbuilder_s' has no member named 'rtype'

c/_cffi_backend.c:4263: error: 'struct funcbuilder_s' has no member named 'atypes'

c/_cffi_backend.c:4263: error: 'FFI_OK' undeclared (first use in this function)

c/_cffi_backend.c: In function 'b_new_function_type':

c/_cffi_backend.c:4280: error: 'FFI_DEFAULT_ABI' undeclared (first use in this function)

c/_cffi_backend.c:4318: error: too many arguments to function 'fb_prepare_cif'

c/_cffi_backend.c:4326: error: 'struct funcbuilder_s' has no member named 'nargs'

c/_cffi_backend.c:4336: error: 'struct funcbuilder_s' has no member named 'nargs'

c/_cffi_backend.c: In function 'convert_from_object_fficallback':

c/_cffi_backend.c:4360: error: 'ffi_arg' undeclared (first use in this function)

c/_cffi_backend.c: At top level:

c/_cffi_backend.c:4432: error: expected ')' before '*' token

c/_cffi_backend.c: In function 'b_callback':

c/_cffi_backend.c:4503: error: 'ffi_closure' undeclared (first use in this function)

c/_cffi_backend.c:4503: error: 'closure' undeclared (first use in this function)

c/_cffi_backend.c:4524: error: 'ffi_arg' undeclared (first use in this function)

c/_cffi_backend.c:4542: warning: implicit declaration of function 'cffi_closure_alloc'

c/_cffi_backend.c:4559: warning: implicit declaration of function 'ffi_prep_closure'

c/_cffi_backend.c:4559: error: 'cif_description_t' has no member named 'cif'

c/_cffi_backend.c:4560: error: 'invoke_callback' undeclared (first use in this function)

c/_cffi_backend.c:4560: error: 'FFI_OK' undeclared (first use in this function)

c/_cffi_backend.c: In function 'init_cffi_backend':

c/_cffi_backend.c:5489: error: 'FFI_DEFAULT_ABI' undeclared (first use in this function)

Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_root/cryptography/setup.py", line 174, in <module>

    "test": PyTest,

  File "/usr/local/lib/python2.7/distutils/core.py", line 112, in setup

    _setup_distribution = dist = klass(attrs)

  File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 260, in __init__

  File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 285, in fetch_build_eggs

  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 631, in resolve

  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 871, in best_match

  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 883, in obtain

  File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 335, in fetch_build_egg

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 595, in easy_install

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 625, in install_item

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 822, in install_eggs

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 1028, in build_and_install

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 1016, in run_setup

distutils.errors.DistutilsError: Setup script exited with error: command 'gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/cryptography
Storing debug log for failure in /root/.pip/pip.log

Solution :

c/_cffi_backend. c:truth:error:ffi. h:No such file or directory
Install the libffi-devel package
yum install libffi-devel

Python Fatal error: Py_Initialize: unable to load the file system codec

terminal open error
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

want to clean up the python installation version, get rid of some files, this is what happened, my hand is out of control……
Solution:

1. sudo vim /etc/profile/
2. export PYTHONHOME=/Library/Frameworks/Python.framework/Versions/3.7
export PYTHONPATH=.:$PYTHONHOME/bin:$PYTHONHOME/site-packages
export PATH=$PATH:$PYTHONHOME:$PYTHONP

Error after run

Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Continue to modify
to delete the environment variables associated with anaconda
Perfect!

Python IndexError: too many indices for array: array is 1-dimensional, but 2 were i..

This is the reason why there are empty tags in the XML files in the dataset.
first of all, what are empty Tags:
& <zhoz>& </ zhoz> this form, that is, there is no value in it
normal should be & < zhoz> 56 this form

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
 
# Move the xml with empty tags and move the corresponding images synchronously
import os
import xml.etree.ElementTree as ET
import shutil
 
origin_ann_dir = '/home/data_1/project/big-obj/RefineDet.PyTorch/data/VOCdevkit/VOC2007/Annotations/'# Set the original tag path to Annos
new_ann_dir = '/home/data_1/project/big-obj/RefineDet.PyTorch/data/VOCdevkit/VOC2007/xml-save/'# Set the new tag path Annotations
origin_pic_dir = '/home/data_1/project/big-obj/RefineDet.PyTorch/data/VOCdevkit/VOC2007/JPEGImages/'
new_pic_dir = '/home/data_1/project/big-obj/RefineDet.PyTorch/data/VOCdevkit/VOC2007/pic-save/'
k=0
p=0
q=0
for dirpaths, dirnames, filenames in os.walk(origin_ann_dir):  
  for filename in filenames:
    print("process...")
    k=k+1
    print(k)
    if os.path.isfile(r'%s%s' %(origin_ann_dir, filename)):   # get the absolute path to the original xml file, isfile() detects if it is a file isdir detects if it is a directory
      origin_ann_path = os.path.join(r'%s%s' %(origin_ann_dir, filename)) # If yes, get absolute path (repeat code)
      new_ann_path = os.path.join(r'%s%s' %(new_ann_dir, filename))
      tree = ET.parse(origin_ann_path)  
      root = tree.getroot()   
      if len(root.findall('object')):
        p=p+1
      else:
        print(filename)
        old_xml = origin_ann_dir + filename
        new_xml = new_ann_dir + filename
        old_pic = origin_pic_dir + filename.replace("xml","jpg")
        new_pic = new_pic_dir + filename.replace("xml","jpg")
        q=q+1
        shutil.move(old_pic, new_pic)
        shutil.move(old_xml, new_xml)
print("ok, ",p)
print("empty, ",q)

Found the XML file that generated the empty tag. The contents are as follows:

<annotation>
	<folder>obj1344</folder>
	<filename>obj1344_frame0000172.jpg</filename>
	<path>D:\Research\valid\obj1344\obj1344_frame0000172.jpg</path>
	<source>
		<database>Unknown</database>
	</source>
	<size>
		<width>480</width>
		<height>270</height>
		<depth>3</depth>
	</size>
	<segmented>0</segmented>
</annotation>

After the XML file is found, the image needs to be annotated again. After opening labelimg to annotate the data, the content of the XML file is as follows:

<annotation>
	<folder>JPEGImages</folder>
	<filename>obj1344_frame0000172.jpg</filename>
	<path>D:\new\SSD-master\datasets\VOC2007\JPEGImages\obj1344_frame0000172.jpg</path>
	<source>
		<database>Unknown</database>
	</source>
	<size>
		<width>480</width>
		<height>270</height>
		<depth>3</depth>
	</size>
	<segmented>0</segmented>
	<object>
		<name>plastic</name>
		<pose>Unspecified</pose>
		<truncated>1</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>181</xmin>
			<ymin>144</ymin>
			<xmax>355</xmax>
			<ymax>270</ymax>
		</bndbox>
	</object>
	<object>
		<name>timestamp</name>
		<pose>Unspecified</pose>
		<truncated>0</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>10</xmin>
			<ymin>5</ymin>
			<xmax>471</xmax>
			<ymax>43</ymax>
		</bndbox>
	</object>
	<object>
		<name>timestamp</name>
		<pose>Unspecified</pose>
		<truncated>1</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>14</xmin>
			<ymin>216</ymin>
			<xmax>480</xmax>
			<ymax>270</ymax>
		</bndbox>
	</object>
</annotation>

Modify and replace the original XML file to run.

How to Solve Python Xlwt ValueError: More than 4094 XFs (styles)

Solution

For style setting functions:

def define_style():
    font = xlwt.Font()
    font.colour_index = 1
    my_style = xlwt.XFStyle()
    my_style.font = font  
    return my_style

When writing data, do not use sheet.write (0, 0, 'data', define)_ Style ()) in this way, change to:

mystyle = define_style()
sheet.write(0, 0, 'data', mystyle)

Example analysis

The following code will report an error

import xlwt


def define_style():
    font = xlwt.Font()
    font.colour_index = 1
    my_style = xlwt.XFStyle()
    my_style.font = font 
    return my_style


if __name__ == '__main__':
    book = xlwt.Workbook(encoding='utf-8')
    sheet = book.add_sheet('sheet1', cell_overwrite_ok=True)
    # mystyle = define_style()
    for i in range(10000):
        sheet.write(i, 0, u'(0,0)', define_style())  
    book.save('my_excel.xlsx')

Modify the part in main function as follows:

	mystyle = define_style()
	for i in range(10000):
        sheet.write(i, 0, u'(0,0)', mystyle)  

Reason analysis

When using xlwt to write data, when passing in the style of xfstyle format, do not use anonymous function to call to write, otherwise after writing 4094 data, it will exceed the threshold, and an error will be reported: valueerror: more than 4094 XFS (styles)

Python RuntimeError: Expected 4-dimensional input for 4-dimensional weight [32, 1, 5, 5]

1. Problem introduction

Today, when using Python to train a model, the data set is read and preprocessed by using the functions provided by python. The network uses the custom CNN, and then there is such a small error as shown in the title when running.

2. Operation error

As follows:

RuntimeError: Expected 4-dimensional input for 4-dimensional weight [32, 1, 5, 5], but got 2-dimensional input of size [32, 784] instead

3. Code

First of all, my own customized CNN network is as follows:

class MNIST_Model(nn.Module):
    def __init__(self, n_in):
        super(MNIST_Model, self).__init__()

        self.conv1 = nn.Sequential(
            nn.Conv2d(in_channels=n_in,
                      out_channels=32,
                      kernel_size=(5, 5),
                      padding=2,
                      stride=1),
        )

        self.maxp1 = nn.MaxPool2d(
                       kernel_size=(2, 2))

        self.conv2 = nn.Sequential(
            nn.Conv2d(in_channels=32,
                      out_channels=64,
                      kernel_size=(5, 5),
                      padding=0,
                      stride=1),
        )

        self.maxp2 = nn.MaxPool2d(kernel_size=(2, 2))
        
        self.fc1 = nn.Sequential(
            nn.Linear(in_features=64 * 5 * 5, out_features=200)  # Mnist
        )

        self.fc2 = nn.Sequential(
            nn.Linear(in_features=200, out_features=10),
            nn.ReLU()
        )


    def forward(self, x):
        x = self.conv1(x)
        x = self.maxp1(x)
        x = self.conv2(x)
        x = self.maxp2(x)
        x = x.contiguous().view(x.size(0), -1)
        x = self.fc1(x)
        x = self.fc2(x)
        return x

Then there is the code in the training model

#Instantiate the network, considering only the use of the CPU
model = model.MNIST_Model(1)
net = model.to(device)
# Define loss function and optimizer
criterion = nn.CrossEntropyLoss()
What is the use of #momentum:momentum factor?
optimizer = optim.SGD(model.parameters(),lr=lr,momentum=momentum)


#Start training First define the array that stores the loss function and accuracy
losses = []
acces = []
#For testing
eval_losses = []
eval_acces = []

for epoch in range(nums_epoches):
    #Clear each training first
    train_loss = 0
    train_acc = 0
    # Set the model to training mode
    model.train()
    #Dynamic learning rate
    if epoch%5 == 0:
        optimizer.param_groups[0]['lr'] *= 0.1
    for img,label in train_loader:
        #Forward propagation, passing the image data into the model
        # out outputs 10 dimensions, respectively the probability of each number, i.e. the score for each category
        out = model(img)
        # Note here that the parameter out is 64*10 and label is a one-dimensional 64
        loss = criterion(out,label)
        #backpropagation
        #optimizer.zero_grad() means to set the gradient to zero, that is, the derivative of loss with respect to weight becomes zero
        optimizer.zero_grad()
        loss.backward()
        #This method updates all the parameters, and once the gradient has been calculated by a function such as backward(), we can call this function
        optimizer.step()
        
        # Record the error 
        train_loss += loss.item()
        
        #Calculate the accuracy of the classification, find the subscript with the highest probability
        _,pred = out.max(1)
        num_correct = (pred == label).sum().item()#record the number of correct labels
        acc = num_correct/img.shape[0]
        train_acc += acc
    losses.append(train_loss/len(train_loader))
    acces.append(train_acc/len(train_loader))
    
    eval_loss = 0
    eval_acc = 0
    model.eval()
    for img,label in test_loader:
        img = img.view(img.size(0),-1)
        
        out = model(img)
        loss = criterion(out,label)
        
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()
        
        eval_loss += loss.item()
        
        _,pred = out.max(1)
        num_correct = (pred == label).sum().item()
        acc = num_correct/img.shape[0]
        eval_acc += acc
    eval_losses.append(eval_loss/len(test_loader))
    eval_acces.append(eval_acc/len(test_loader))
    

    print('epoch:{},Train Loss:{:.4f},Train Acc:{:.4f},Test Loss:{:.4f},Test Acc:{:.4f}'
             .format(epoch,train_loss/len(train_loader),train_acc/len(train_loader),
                    eval_loss/len(test_loader),eval_acc/len(test_loader)))

4. Analyze the reasons

Locate error location

Traceback (most recent call last):
  File "train.py", line 73, in <module>
    out = model(img)
  File "/home/gzdx/anaconda3/envs/Torch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/gzdx/wyf/PARAD/model.py", line 48, in forward
    x = self.conv1(x)
  File "/home/gzdx/anaconda3/envs/Torch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/gzdx/anaconda3/envs/Torch/lib/python3.7/site-packages/torch/nn/modules/container.py", line 119, in forward
    input = module(input)
  File "/home/gzdx/anaconda3/envs/Torch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/gzdx/anaconda3/envs/Torch/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 399, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "/home/gzdx/anaconda3/envs/Torch/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 396, in _conv_forward
    self.padding, self.dilation, self.groups)
RuntimeError: Expected 4-dimensional input for 4-dimensional weight [32, 1, 5, 5], but got 2-dimensional input of size [32, 784] instead

As you can see, this is roughly the result of our incoming data input into CNN network, and then due to different dimensions. Because we input four dimensions, but we get two dimensions.

  File "train.py", line 73, in <module>
    out = model(img)

5. Solutions

For this kind of problem, there are many different solutions on the Internet. This person also refers to some ideas given by others on the Internet, and then modifies them by himself, and the error is solved, as shown below:

for i,data in enumerate(train_loader):
        #Forward propagation, passing the image data into the model
        # out output 10 dimensions, respectively the probability of each number, i.e. the score of each category
        inputs, labels = data
        inputs,labels = data[0].to(device), data[1].to(device)
        # inputs torch.Size([32, 1, 28, 28])
        out = model(inputs)

The solution is also very simple. At the beginning of the training, the data will be assigned according to this reading method, and then it will be passed into the model without the above error.

6. Complete code

import numpy as np
import model
import torch

#Importing PyTorch's built-in mnist data
from torchvision.datasets import mnist

#Import pre-processing module
from torchvision import transforms
from torch.utils.data import DataLoader

#Importing neural network tools
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim

#Define the hyperparameters to be used later
train_batch_size = 32
test_batch_size = 32

#Learning rate and number of training sessions
learning_rate = 0.01
nums_epoches = 50

#Parameters used when optimizer
lr = 0.1
momentum = 0.5

#Use compose to specify the preprocessor
transform = transforms.Compose([transforms.ToTensor(),transforms.Normalize([0.5],[0.5])])

#Download the data, create a new data folder in the project folder to store the downloaded data
train_dataset = mnist.MNIST('./data', train=True, transform=transform, target_transform=None, download=False)
test_dataset = mnist.MNIST('./data', train=False, transform=transform, target_transform=None, download=False)

#Data loaders, combined datasets and samplers, and single or multi-process iterators on datasets
train_loader = DataLoader(train_dataset, batch_size=train_batch_size, shuffle=True, num_workers=0)
test_loader = DataLoader(test_dataset, batch_size=test_batch_size, shuffle=False)

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

#Instantiate the network, considering only the use of the CPU
model = model.MNIST_Model(1)
net = model.to(device)
# Define loss function and optimizer
criterion = nn.CrossEntropyLoss()
What is the use of #momentum:momentum factor?
optimizer = optim.SGD(model.parameters(),lr=lr,momentum=momentum)




#Start the training by defining an array that stores the loss function and the accuracy
losses = []
acces = []
# test with
eval_losses = []
eval_acces = []

for epoch in range(nums_epoches):
    #Clear each training first
    train_loss = 0
    train_acc = 0
    # Set the model to training mode
    model.train()

    #动态学习率
    if epoch%5 == 0:
        optimizer.param_groups[0]['lr'] *= 0.1
    for i,data in enumerate(train_loader):
        #Forward propagation, passing the image data into the model
        # out output 10 dimensions, respectively the probability of each number, i.e. the score of each category
        inputs, labels = data
        inputs,labels = data[0].to(device), data[1].to(device)
        out = model(inputs)
        #Note here that the parameter out is 64*10 and label is 64 in one dimension
        loss = criterion(out,labels)
        #backpropagation
        #optimizer.zero_grad() means to set the gradient to zero, that is, to make the derivative of loss with respect to weight zero
        optimizer.zero_grad()
        loss.backward()
        # This method updates all the parameters, and once the gradient has been calculated by a function like backward(), we can call this function
        optimizer.step()
        
        #Record the error 
        train_loss += loss.item()
        
        # Calculate the accuracy of the classification, find the subscript with the highest probability
        _,pred = out.max(1)
        num_correct = (pred == labels).sum().item() # Record the number of correct labels
        acc = num_correct/inputs.shape[0]
        train_acc += acc
    losses.append(train_loss/len(train_loader))
    acces.append(train_acc/len(train_loader))
    print('Finished Training') 

    # save
    PATH = './model/mnist_net.pth'
    torch.save(net.state_dict(), PATH)
    
    eval_loss = 0
    eval_acc = 0
    model.eval()
    for i,data in enumerate(test_loader):
        inputs, labels = data
        inputs,labels = data[0].to(device), data[1].to(device)
        out = model(inputs)
        loss = criterion(out,labels)
        
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()
        
        eval_loss += loss.item()
        
        _,pred = out.max(1)
        num_correct = (pred == labels).sum().item()
        acc = num_correct/inputs.shape[0]
        eval_acc += acc
    eval_losses.append(eval_loss/len(test_loader))
    eval_acces.append(eval_acc/len(test_loader))
    

    print('epoch:{},Train Loss:{:.4f},Train Acc:{:.4f},Test Loss:{:.4f},Test Acc:{:.4f}'
             .format(epoch,train_loss/len(train_loader),train_acc/len(train_loader),
                    eval_loss/len(test_loader),eval_acc/len(test_loader)))

urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=‘localhost‘, port=8097): Max retries excee

After using visdom, the following problem occurs.

requests.exceptions.ConnectionError: HTTPConnectionPool(host=’localhost’, port=8097): Max retries exceeded with url: /env/main (Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection object at 0x0000027F8769B7F0>: Failed to establish a new connection: [WinError 10061] Unable to connect due to aggressive rejection by the target computer.’))
[WinError 10061] Unable to connect because the target computer is actively rejecting.
Visdom python client failed to establish socket to get messages from the server. This feature is optional and can be disabled by initializing Visdom with `use_incoming_socket=False`, which will prevent waiting for this request to timeout.
Setting up a new session…

visdom The above problem will also occur if it is not started.
Solution.

python -m visdom.server