问:
Unable to install Pillow for Django App using Terminal on Namecheap Shared hosting
I was going to deploy my Django App on Namecheap shared hosting. My app needs Pillow to be able to run perfectly. But while installing pillow using pip install Pillow in Namecheap's Terminal, I get the error. I installed Django and other libraries successfully. But while installing Pillow, it gives me this error.

```Collecting Pillow==8.4.0
  Using cached Pillow-8.4.0.tar.gz (49.4 MB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: Pillow
  Building wheel for Pillow (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/abduxdcv/virtualenv/iffi-store-app/3.8/bin/python3.8_bin -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/setup.py'"'"'; __file__='"'"'/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-vyxwq5up
       cwd: /tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/
  Complete output (143 lines):
  /opt/alt/python38/lib64/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
    warnings.warn(msg)
  /opt/alt/python38/lib64/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'project_urls'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.8
  creating build/lib.linux-x86_64-3.8/PIL
  copying src/PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
  copying src/PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
  running egg_info
  writing src/Pillow.egg-info/PKG-INFO
  writing dependency_links to src/Pillow.egg-info/dependency_links.txt
  writing top-level names to src/Pillow.egg-info/top_level.txt
  reading manifest file 'src/Pillow.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching '*.c'
  warning: no files found matching '*.h'
  warning: no files found matching '*.sh'
  warning: no previously-included files found matching '.appveyor.yml'
  warning: no previously-included files found matching '.clang-format'
  warning: no previously-included files found matching '.coveragerc'
  warning: no previously-included files found matching '.editorconfig'
  warning: no previously-included files found matching '.readthedocs.yml'
  warning: no previously-included files found matching 'codecov.yml'
  warning: no previously-included files matching '.git*' found anywhere in distribution
  warning: no previously-included files matching '*.pyc' found anywhere in distribution
  warning: no previously-included files matching '*.so' found anywhere in distribution
  no previously-included directories found matching '.ci'
  writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
  running build_ext
  building 'PIL._imaging' extension
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/src
  creating build/temp.linux-x86_64-3.8/src/libImaging
  building 'PIL._imagingft' extension
  /opt/rh/devtoolset-7/root/usr/bin/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result-Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fPIC -I/usr/include/freetype2 -I/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac -I/home/abduxdcv/virtualenv/iffi-store-app/3.8/include -I/usr/include -I/opt/alt/python38/include/python3.8 -c src/_imagingmorph.c -o build/temp.linux-x86_64-3.8/src/_imagingmorph.o
  unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
  unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
  unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
  error: command '/opt/rh/devtoolset-7/root/usr/bin/gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for Pillow
  Running setup.py clean for Pillow
Failed to build Pillow
Installing collected packages: Pillow
    Running setup.py install for Pillow ... error
    ERROR: Command errored out with exit status 1:
     command: /home/abduxdcv/virtualenv/iffi-store-app/3.8/bin/python3.8_bin -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/setup.py'"'"'; __file__='"'"'/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/setup.py'"'"';f = getattr(tokenize,'"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-j3nzm_7c/install-record.txt --single-version-externally-managed --compile --install-headers /home/abduxdcv/virtualenv/iffi-store-app/3.8/include/site/python3.8/Pillow
         cwd: /tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/
    Complete output (143 lines):
    /opt/alt/python38/lib64/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
      warnings.warn(msg)
    /opt/alt/python38/lib64/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'project_urls'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.8
    creating build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageWin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/FtexImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PdfParser.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageCms.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageDraw2.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageFilter.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/CurImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/FontFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageDraw.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/McIdasImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ContainerIO.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/WmfImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/FitsStubImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/__main__.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/TiffTags.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/__init__.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PcdImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/Hdf5StubImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/_util.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageShow.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageStat.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/SgiImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageMode.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/IcnsImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/TiffImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/FliImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PaletteFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/GbrImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PSDraw.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/GimpPaletteFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/_binary.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageGrab.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/MspImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImagePalette.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/SpiderImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/GimpGradientFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageMath.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PsdImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/IcoImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PalmImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/features.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/FpxImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/GifImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ExifTags.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageEnhance.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageSequence.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PyAccess.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/TgaImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/Jpeg2KImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/BufrStubImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/XpmImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/XVThumbImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageChops.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PdfImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/DcxImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageTk.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PpmImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageQt.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/MpoImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/MicImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageTransform.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/WebPImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageMorph.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/TarIO.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PcxImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/GdImageFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageOps.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageFont.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/JpegImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageColor.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/Image.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/SunImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/XbmImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/MpegImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/_tkinter_finder.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/GribStubImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImagePath.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PngImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PcfFontFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/DdsImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/_version.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/WalImageFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/BdfFontFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/BlpImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/JpegPresets.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/IptcImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    running egg_info
    writing src/Pillow.egg-info/PKG-INFO
    writing dependency_links to src/Pillow.egg-info/dependency_links.txt
    writing top-level names to src/Pillow.egg-info/top_level.txt
    reading manifest file 'src/Pillow.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.c'
    warning: no files found matching '*.h'
    warning: no files found matching '*.sh'
    warning: no previously-included files found matching '.appveyor.yml'
    warning: no previously-included files found matching '.clang-format'
    warning: no previously-included files found matching '.coveragerc'
    warning: no previously-included files found matching '.editorconfig'
    warning: no previously-included files found matching '.readthedocs.yml'
    warning: no previously-included files found matching 'codecov.yml'
    warning: no previously-included files matching '.git*' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
    no previously-included directories found matching '.ci'
    writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
    running build_ext
    building 'PIL._imaging' extension
    building 'PIL._imagingft' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/src
    building 'PIL._imagingtk' extension
    /opt/rh/devtoolset-7/root/usr/bin/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fPIC -I/usr/include/freetype2 -I/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac -I/home/abduxdcv/virtualenv/iffi-store-app/3.8/include -I/usr/include -I/opt/alt/python38/include/python3.8 -c src/_imagingft.c -o build/temp.linux-x86_64-3.8/src/_imagingft.o
    creating build/temp.linux-x86_64-3.8/src/libImaging
    building 'PIL._imagingmath' extension
    /opt/rh/devtoolset-7/root/usr/bin/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fPIC -I/usr/include/freetype2 -I/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac -I/home/abduxdcv/virtualenv/iffi-store-app/3.8/include -I/usr/include -I/opt/alt/python38/include/python3.8 -c src/_imagingmath.c -o build/temp.linux-x86_64-3.8/src/_imagingmath.o
    unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
    /opt/rh/devtoolset-7/root/usr/bin/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fPIC -DHAVE_LIBJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -DHAVE_XCB -DPILLOW_VERSION="8.4.0" -I/usr/include/freetype2 -I/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac -I/home/abduxdcv/virtualenv/iffi-store-app/3.8/include -I/usr/include -I/opt/alt/python38/include/python3.8 -c src/_imaging.c -o build/temp.linux-x86_64-3.8/src/_imaging.o
    unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
    creating build/temp.linux-x86_64-3.8/src/Tk
    building 'PIL._imagingmorph' extension
    /opt/rh/devtoolset-7/root/usr/bin/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fPIC -I/usr/include/freetype2 -I/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac -I/home/abduxdcv/virtualenv/iffi-store-app/3.8/include -I/usr/include -I/opt/alt/python38/include/python3.8 -c src/_imagingtk.c -o build/temp.linux-x86_64-3.8/src/_imagingtk.o
    /opt/rh/devtoolset-7/root/usr/bin/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fPIC -I/usr/include/freetype2 -I/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac -I/home/abduxdcv/virtualenv/iffi-store-app/3.8/include -I/usr/include -I/opt/alt/python38/include/python3.8 -c src/_imagingmorph.c -o build/temp.linux-x86_64-3.8/src/_imagingmorph.o
    unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
    unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
    unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
    error: command '/opt/rh/devtoolset-7/root/usr/bin/gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/abduxdcv/virtualenv/iffi-store-app/3.8/bin/python3.8_bin -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0]= '"'"'/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/setup.py'"'"'; __file__='"'"'/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-j3nzm_7c/install-record.txt --single-version-externally-managed --compile --install-headers /home/abduxdcv/virtualenv/iffi-store-app/3.8/include/site/python3.8/Pillow Check the logs for full command output.
```

I have tried to upgrade pip, but that did not solve the issue. Does anyone know whats wrong?

答:
This may not be the best way to do it, but it has proved time and again to be effective and easy workaround.

This method is for Namecheap shared hosting as the question indicated.
Assuming you already Installed pillow Inside your local environment. Select all pillow file inside the "site-packages" folder and zip compress them as a copy.

Now go back to your namecheap hosting file manager and go to the location (current projects site-packages inside the virtual environment)
/home/abduxdcv/virtualenv/iffi-store-app/3.8/lib/python3.8/site-packages

(/home/shared-hosting-name/virtualenv/name-of-current-app/python-version/lib/python3.version/site-packages)

Upload the zipped PILLOW files and extract them into the site-packages folder you're already in (Note location above)

Everything should work fine now. Confirm by running python3 manage.py makemigrations and migrate respectively. Since your projects uses models.ImageField() an error should occur if PILLOW isn't working. If no errors continue with your project.

Unfortunately I can't include screenshots of the said step because of reputation. I will look for workaround.

Step1: Zip compress installed pillow files locally.

Step 2: Upload the zipped PILLOW files and extract into Namecheap hosted target projects site-packages inside the virtual environment.

PS:
This is a quick answer, apologies for any bad construction.

Update: link to github gist Github Gist

Body:
I was going to deploy my Django App on Namecheap shared hosting. My app needs Pillow to be able to run perfectly. But while installing pillow using pip install Pillow in Namecheap's Terminal, I get the error. I installed Django and other libraries successfully. But while installing Pillow, it gives me this error.

Collecting Pillow==8.4.0
  Using cached Pillow-8.4.0.tar.gz (49.4 MB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: Pillow
  Building wheel for Pillow (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/abduxdcv/virtualenv/iffi-store-app/3.8/bin/python3.8_bin -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/setup.py'"'"'; __file__='"'"'/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-vyxwq5up
       cwd: /tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/
  Complete output (143 lines):
  /opt/alt/python38/lib64/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
    warnings.warn(msg)
  /opt/alt/python38/lib64/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'project_urls'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.8
  creating build/lib.linux-x86_64-3.8/PIL
  copying src/PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
  copying src/PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
  running egg_info
  writing src/Pillow.egg-info/PKG-INFO
  writing dependency_links to src/Pillow.egg-info/dependency_links.txt
  writing top-level names to src/Pillow.egg-info/top_level.txt
  reading manifest file 'src/Pillow.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching '*.c'
  warning: no files found matching '*.h'
  warning: no files found matching '*.sh'
  warning: no previously-included files found matching '.appveyor.yml'
  warning: no previously-included files found matching '.clang-format'
  warning: no previously-included files found matching '.coveragerc'
  warning: no previously-included files found matching '.editorconfig'
  warning: no previously-included files found matching '.readthedocs.yml'
  warning: no previously-included files found matching 'codecov.yml'
  warning: no previously-included files matching '.git*' found anywhere in distribution
  warning: no previously-included files matching '*.pyc' found anywhere in distribution
  warning: no previously-included files matching '*.so' found anywhere in distribution
  no previously-included directories found matching '.ci'
  writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
  running build_ext
  building 'PIL._imaging' extension
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/src
  creating build/temp.linux-x86_64-3.8/src/libImaging
  building 'PIL._imagingft' extension
  /opt/rh/devtoolset-7/root/usr/bin/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result-Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fPIC -I/usr/include/freetype2 -I/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac -I/home/abduxdcv/virtualenv/iffi-store-app/3.8/include -I/usr/include -I/opt/alt/python38/include/python3.8 -c src/_imagingmorph.c -o build/temp.linux-x86_64-3.8/src/_imagingmorph.o
  unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
  unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
  unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
  error: command '/opt/rh/devtoolset-7/root/usr/bin/gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for Pillow
  Running setup.py clean for Pillow
Failed to build Pillow
Installing collected packages: Pillow
    Running setup.py install for Pillow ... error
    ERROR: Command errored out with exit status 1:
     command: /home/abduxdcv/virtualenv/iffi-store-app/3.8/bin/python3.8_bin -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/setup.py'"'"'; __file__='"'"'/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/setup.py'"'"';f = getattr(tokenize,'"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-j3nzm_7c/install-record.txt --single-version-externally-managed --compile --install-headers /home/abduxdcv/virtualenv/iffi-store-app/3.8/include/site/python3.8/Pillow
         cwd: /tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/
    Complete output (143 lines):
    /opt/alt/python38/lib64/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
      warnings.warn(msg)
    /opt/alt/python38/lib64/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'project_urls'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.8
    creating build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageWin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/FtexImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PdfParser.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageCms.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageDraw2.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageFilter.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/CurImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/FontFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageDraw.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/McIdasImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ContainerIO.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/WmfImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/FitsStubImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/__main__.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/TiffTags.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/__init__.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PcdImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/Hdf5StubImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/_util.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageShow.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageStat.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/SgiImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageMode.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/IcnsImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/TiffImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/FliImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PaletteFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/GbrImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PSDraw.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/GimpPaletteFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/_binary.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageGrab.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/MspImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImagePalette.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/SpiderImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/GimpGradientFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageMath.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PsdImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/IcoImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PalmImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/features.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/FpxImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/GifImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ExifTags.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageEnhance.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageSequence.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PyAccess.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/TgaImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/Jpeg2KImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/BufrStubImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/XpmImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/XVThumbImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageChops.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PdfImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/DcxImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageTk.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PpmImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageQt.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/MpoImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/MicImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageTransform.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/WebPImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageMorph.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/TarIO.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PcxImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/GdImageFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageOps.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageFont.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/JpegImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImageColor.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/Image.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/SunImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/XbmImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/MpegImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/_tkinter_finder.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/GribStubImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImagePath.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PngImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/PcfFontFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/DdsImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/_version.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/WalImageFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/BdfFontFile.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/BlpImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/JpegPresets.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/IptcImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    copying src/PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-3.8/PIL
    running egg_info
    writing src/Pillow.egg-info/PKG-INFO
    writing dependency_links to src/Pillow.egg-info/dependency_links.txt
    writing top-level names to src/Pillow.egg-info/top_level.txt
    reading manifest file 'src/Pillow.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.c'
    warning: no files found matching '*.h'
    warning: no files found matching '*.sh'
    warning: no previously-included files found matching '.appveyor.yml'
    warning: no previously-included files found matching '.clang-format'
    warning: no previously-included files found matching '.coveragerc'
    warning: no previously-included files found matching '.editorconfig'
    warning: no previously-included files found matching '.readthedocs.yml'
    warning: no previously-included files found matching 'codecov.yml'
    warning: no previously-included files matching '.git*' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
    no previously-included directories found matching '.ci'
    writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
    running build_ext
    building 'PIL._imaging' extension
    building 'PIL._imagingft' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/src
    building 'PIL._imagingtk' extension
    /opt/rh/devtoolset-7/root/usr/bin/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fPIC -I/usr/include/freetype2 -I/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac -I/home/abduxdcv/virtualenv/iffi-store-app/3.8/include -I/usr/include -I/opt/alt/python38/include/python3.8 -c src/_imagingft.c -o build/temp.linux-x86_64-3.8/src/_imagingft.o
    creating build/temp.linux-x86_64-3.8/src/libImaging
    building 'PIL._imagingmath' extension
    /opt/rh/devtoolset-7/root/usr/bin/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fPIC -I/usr/include/freetype2 -I/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac -I/home/abduxdcv/virtualenv/iffi-store-app/3.8/include -I/usr/include -I/opt/alt/python38/include/python3.8 -c src/_imagingmath.c -o build/temp.linux-x86_64-3.8/src/_imagingmath.o
    unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
    /opt/rh/devtoolset-7/root/usr/bin/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fPIC -DHAVE_LIBJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -DHAVE_XCB -DPILLOW_VERSION="8.4.0" -I/usr/include/freetype2 -I/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac -I/home/abduxdcv/virtualenv/iffi-store-app/3.8/include -I/usr/include -I/opt/alt/python38/include/python3.8 -c src/_imaging.c -o build/temp.linux-x86_64-3.8/src/_imaging.o
    unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
    creating build/temp.linux-x86_64-3.8/src/Tk
    building 'PIL._imagingmorph' extension
    /opt/rh/devtoolset-7/root/usr/bin/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fPIC -I/usr/include/freetype2 -I/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac -I/home/abduxdcv/virtualenv/iffi-store-app/3.8/include -I/usr/include -I/opt/alt/python38/include/python3.8 -c src/_imagingtk.c -o build/temp.linux-x86_64-3.8/src/_imagingtk.o
    /opt/rh/devtoolset-7/root/usr/bin/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -D_GNU_SOURCE -fPIC -fwrapv -D_GNU_SOURCE -fPIC -fwrapv -O2 -fno-semantic-interposition -pthread -Wno-unused-result -Wsign-compare -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fPIC -I/usr/include/freetype2 -I/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac -I/home/abduxdcv/virtualenv/iffi-store-app/3.8/include -I/usr/include -I/opt/alt/python38/include/python3.8 -c src/_imagingmorph.c -o build/temp.linux-x86_64-3.8/src/_imagingmorph.o
    unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
    unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
    unable to execute '/opt/rh/devtoolset-7/root/usr/bin/gcc': No such file or directory
    error: command '/opt/rh/devtoolset-7/root/usr/bin/gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/abduxdcv/virtualenv/iffi-store-app/3.8/bin/python3.8_bin -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0]= '"'"'/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/setup.py'"'"'; __file__='"'"'/tmp/pip-install-u2_5lsia/pillow_aabaeed7df664fd985a82d84f11f5eac/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-j3nzm_7c/install-record.txt --single-version-externally-managed --compile --install-headers /home/abduxdcv/virtualenv/iffi-store-app/3.8/include/site/python3.8/Pillow Check the logs for full command output.

I have tried to upgrade pip, but that did not solve the issue. Does anyone know whats wrong?


来源: stackexchange

问:
Change orders status by order number in Woocommerce
I would like to know if there is a way that i can change status of a bunch of orders with a list of order numbers, exemple :
Change status of this orders from "In progess" to "Completed"

638
637
636
635
634

Thanks

答:
You can loop through ids and use wp_update_post() to update stautus.
Here's a list of wc order statuses.</p>
```<code>$order_ids = [ 638, 637, 636, 635, 634 ];

foreach( $order_ids as $id ) {
   wp_update_post([
       'ID'          => $id,
       'post_status' => 'wc-completed'
   ]);
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
You can loop through ids and use wp_update_post() to update stautus.
Here's a list of wc order statuses.

$order_ids = [ 638, 637, 636, 635, 634 ];

foreach( $order_ids as $id ) {
   wp_update_post([
       'ID'          => $id,
       'post_status' => 'wc-completed'
   ]);
}


问:
how to comment code blocks (that you want to remove)in the code page word press
I need to disable best selling featured products etc.</p>

```<code>    </main><!-- #main -->
</div><!-- #primary -->
</code>```

答:
You have two ways to do that. Here is an example

Another way is :

```<code><?php /*echo "<div>
Here
are some
details
</div>" */;?>
</code>```

Body:
You have two ways to do that. Here is an example

<!--div>Here are some elements</div-->
Another way is :

<?php /*echo "<div>
Here
are some
details
</div>" */;?>


问:
kubelet failed with kubelet cgroup driver: "cgroupfs" is different from docker cgroup driver: "systemd"
Configuration for cgroup driver is right in /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

```<code>Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=systemd"
</code>```

I also checked the Environment with cli

```<code>$ systemctl show --property=Environment kubelet | cat
Environment=KUBELET_KUBECONFIG_ARGS=--kubeconfig=/etc/kubernetes/kubelet.conf\x20--require-kubeconfig=true KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests\x20--allow-privileged=true KUBELET_NETWORK_ARGS=--network-plugin=cni\x20--cni-conf-dir=/etc/cni/net.d\x20--cni-bin-dir=/opt/cni/bin KUBELET_DNS_ARGS=--cluster-dns=10.96.0.10\x20--cluster-domain=cluster.local KUBELET_AUTHZ_ARGS=--authorization-mode=Webhook\x20--client-ca-file=/etc/kubernetes/pki/ca.crt KUBELET_CADVISOR_ARGS=--cadvisor-port=0 KUBELET_CGROUP_ARGS=--cgroup-driver=systemd
</code>```

KUBELET_CGROUP_ARGS=--cgroup-driver=systemd

How to reproduce it:

yum install -y docker-1.12.6

systemctl enable docker && systemctl start docker

setenforce 0

yum install -y kubelet kubeadm

systemctl enable kubelet && systemctl start kubelet

systemctl daemon-reload

systemctl restart kubelet

kubelet log

Environment:

Kubernetes version (use kubectl version): 1.7.3

Cloud provider or hardware configuration**:   4 core 16G RAM

OS (e.g. from /etc/os-release):  CentOS Linux 7 (Core)

Kernel (e.g. uname -a): Linux 10-8-108-92 3.10.0-327.22.2.el7.x86_64 #1 SMP Thu Jun 23 17:05:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Install tools: kubeadm

答:
https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/configure-cgroup-driver/

Using the cgroupfs driver
As this guide explains using the cgroupfs driver with kubeadm is not recommended.

To continue using cgroupfs and to prevent kubeadm upgrade from modifying the KubeletConfiguration cgroup driver on existing setups, you must be explicit about its value. This applies to a case where you do not wish future versions of kubeadm to apply the systemd driver by default.

See the below section on "Modify the kubelet ConfigMap" for details on how to be explicit about the value.

If you wish to configure a container runtime to use the cgroupfs driver, you must refer to the documentation of the container runtime of your choice

Go to change config docker cgroupfs to systemd

edit:
/etc/docker/daemon.json

```<code>{
  "exec-opts": ["native.cgroupdriver=systemd"]
}
</code>```

restart service docker

```<code>systemctl daemon-reload && systemctl restart docker && systemctl restart kubelet
</code>```

show the config in

```<code>docker info |grep Cgroup
</code>```

Body:
Configuration for cgroup driver is right in /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=systemd"

I also checked the Environment with cli

$ systemctl show --property=Environment kubelet | cat
Environment=KUBELET_KUBECONFIG_ARGS=--kubeconfig=/etc/kubernetes/kubelet.conf\x20--require-kubeconfig=true KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests\x20--allow-privileged=true KUBELET_NETWORK_ARGS=--network-plugin=cni\x20--cni-conf-dir=/etc/cni/net.d\x20--cni-bin-dir=/opt/cni/bin KUBELET_DNS_ARGS=--cluster-dns=10.96.0.10\x20--cluster-domain=cluster.local KUBELET_AUTHZ_ARGS=--authorization-mode=Webhook\x20--client-ca-file=/etc/kubernetes/pki/ca.crt KUBELET_CADVISOR_ARGS=--cadvisor-port=0 KUBELET_CGROUP_ARGS=--cgroup-driver=systemd

KUBELET_CGROUP_ARGS=--cgroup-driver=systemd

How to reproduce it:

yum install -y docker-1.12.6

systemctl enable docker && systemctl start docker

setenforce 0

yum install -y kubelet kubeadm

systemctl enable kubelet && systemctl start kubelet

systemctl daemon-reload

systemctl restart kubelet

kubelet log

Environment:

Kubernetes version (use kubectl version): 1.7.3

Cloud provider or hardware configuration**:   4 core 16G RAM

OS (e.g. from /etc/os-release):  CentOS Linux 7 (Core)

Kernel (e.g. uname -a): Linux 10-8-108-92 3.10.0-327.22.2.el7.x86_64 #1 SMP Thu Jun 23 17:05:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Install tools: kubeadm

Body:
https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/configure-cgroup-driver/

Using the cgroupfs driver
As this guide explains using the cgroupfs driver with kubeadm is not recommended.

To continue using cgroupfs and to prevent kubeadm upgrade from modifying the KubeletConfiguration cgroup driver on existing setups, you must be explicit about its value. This applies to a case where you do not wish future versions of kubeadm to apply the systemd driver by default.

See the below section on "Modify the kubelet ConfigMap" for details on how to be explicit about the value.

If you wish to configure a container runtime to use the cgroupfs driver, you must refer to the documentation of the container runtime of your choice

Go to change config docker cgroupfs to systemd

edit:
/etc/docker/daemon.json

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

restart service docker

systemctl daemon-reload && systemctl restart docker && systemctl restart kubelet

show the config in

docker info |grep Cgroup


问:
Is it possible to change Google sheet sidebar heading background color?
I want to change Google sheet sidebar heading background color. Have any idea to change background color using app script or any manual setting. Please help.

答:
You can do this with this code :

function onOpen() {
  SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
      .createMenu('Custom Menu')
      .addItem('Show sidebar', 'showSidebar')
      .addToUi();
}

function showSidebar() {
  var html = HtmlService.createHtmlOutputFromFile('Page')
      .setTitle('My custom sidebar');
  SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
      .showSidebar(html);
}```

https://developers.google.com/apps-script/guides/dialogs

Body:
You can do this with this code :

function onOpen() {
  SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
      .createMenu('Custom Menu')
      .addItem('Show sidebar', 'showSidebar')
      .addToUi();
}

function showSidebar() {
  var html = HtmlService.createHtmlOutputFromFile('Page')
      .setTitle('My custom sidebar');
  SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
      .showSidebar(html);
}

https://developers.google.com/apps-script/guides/dialogs


问:
Declaring variable without var sign in beginning?
I have seen class that states var _hello_kitty = array(); why they dont use $? i tried to make it public and static and it does not work without adding $i.e. public static $_hello_kitty = array();

now when i do add $ other functions who reference it by _hello_kitty stop working.

EDIT: OOOPS was my bad i somehow removed $ from there, i looped up original file and its there. but its still referencing like $this->_tpl_vars[$tpl_var] = &$value without $ and i cannot use self::_tpl_vars[$tpl_var];

now i did use self::$_tpl_vars[$tpl_var]; but now error comes up array_merge() [function.array-merge]: Argument #1 is not an array i

答:
That's how the syntax for PHP class properties works.

You define the property with the dollar-sign, eg

```<code>public $publicProperty;
protected $protectedProperty;
private $privatePropertyKeepOutLulz;
</code>```

When referencing them from a class instance (ie object), you omit the dollar-sign, eg

```<code>$obj->publicProperty;
$this->protectedProperty;
$this->privatePropertyKeepOutLulz;
</code>```

Update

Static properties are declared using the static keyword

```<code>public static $publicStaticProperty;
private static $privateStaticProperty;
</code>```

You then reference them like so

```<code>// From outside the class (only applies to public properties)
ClassName::$publicStaticProperty;

// From within the class
self::$privateStaticProperty;

// From a descendant class (public or protected only)
parent::$property;
</code>```

ContentLicense: CC BY-SA 3.0

Body:
That's how the syntax for PHP class properties works.

You define the property with the dollar-sign, eg

public $publicProperty;
protected $protectedProperty;
private $privatePropertyKeepOutLulz;

When referencing them from a class instance (ie object), you omit the dollar-sign, eg

$obj->publicProperty;
$this->protectedProperty;
$this->privatePropertyKeepOutLulz;

Update

Static properties are declared using the static keyword

public static $publicStaticProperty;
private static $privateStaticProperty;

You then reference them like so

// From outside the class (only applies to public properties)
ClassName::$publicStaticProperty;

// From within the class
self::$privateStaticProperty;

// From a descendant class (public or protected only)
parent::$property;


问:
permission related issues dovecot postfix
I have the following error message in the dovecot errors & warnings log after I've tried to rebuild my mail server.

Prior to these errors, I updated my aging system to the latest, and lots of things broke.  The configuration was confetti, so I attempted to rebuild the mail server.  To get this error, I simply login to Roundcube mail.  I'm able to login, however I cant see any emails.

I'm seeing two issues in the error, just not sure how to fix it.

```<code>Feb 06 18:07:15 imap(brad@nostalgicmail.com)<96785><ZgOYWl3XtMwX/pCT>: Error: chdir(/var/vmail/nostalgicmail.com/brad@nostalgicmail.com/) failed: Permission denied (euid=150(<unknown>) egid=8(mail) missing +x perm: /var/vmail/nostalgicmail.com, dir owned by 2000:2000 mode=0700)

Feb 06 18:07:15 imap(brad@nostalgicmail.com)<96785><ZgOYWl3XtMwX/pCT>: Error: stat(/var/vmail/nostalgicmail.com/brad@nostalgicmail.com/subscriptions) failed: Permission denied
</code>```

Issue 1: chdir(/var/vmail/nostalgicmail.com/brad@nostalgicmail.com/)

This is not the correct directory, it should be /var/vmail/nostalgicmail.com/brad

Issue 2: Permission denied (euid=150() egid=8(mail) missing +x perm: /var/vmail/nostalgicmail.com, dir owned by 2000:2000 mode=0700)

This might be fixed after Issue 1 is corrected.

I do have other work to do to complete the server, such as making sure all SSL keys are correct, reintegrating sieve & spamassassin, dkim, spf, and so on.  For now, I just need the email server to function.

My directory setup looks like so:

```<code>zion@hwsrv-890039:~$ sudo ls -Al /var/vmail/
total 16
drwx------  5 vmail vmail 4096 Sep 10 19:06 kingmobiletransport.com
drwx------ 11 vmail vmail 4096 Jan 20 18:49 nostalgicmail.com
drwx------  3 vmail vmail 4096 Aug 15 05:28 sites-by-brad.com
drwx------  2 vmail vmail 4096 Feb  5 20:26 spamassassin
zion@hwsrv-890039:~$ sudo ls -Al /var/vmail/nostalgicmail.com/
total 36
drwx------ 4 vmail vmail 4096 Jan 10 19:47 brad
drwx------ 3 vmail vmail 4096 Jan 10 03:59 chronicle
drwx------ 3 vmail vmail 4096 Jul 22  2021 dirtywill
drwx------ 3 vmail vmail 4096 Jul  6  2021 emerald
drwx------ 3 vmail vmail 4096 Jul  6  2021 mickey
drwx------ 3 vmail vmail 4096 Jul  9  2021 mistyblue
drwx------ 4 vmail vmail 4096 Sep 21 20:54 mquin007
drwx------ 3 vmail vmail 4096 Jan 20 18:49 tribeofriche
drwx------ 3 vmail vmail 4096 Jul 29  2021 weather
zion@hwsrv-890039:~$ sudo ls -Al /var/vmail/nostalgicmail.com/brad/
total 12
lrwxrwxrwx  1 vmail vmail   21 Jul  9  2021 .dovecot.sieve -> sieve/roundcube.sieve
-rw-------  1 vmail vmail  726 Jan 10 19:47 .dovecot.svbin
drwx------ 22 vmail vmail 4096 Feb  5 21:57 Maildir
drwx------  3 vmail vmail 4096 Jan 10 19:35 sieve
zion@hwsrv-890039:~$
</code>```

Dovecot config looks like so:

```<code>zion@hwsrv-890039:~$ sudo doveconf -n > dovecot_config
zion@hwsrv-890039:~$ cat dovecot_config
# 2.3.13 (89f716dc2): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.13 (cdd19fe3)
# OS: Linux 5.10.0-11-cloud-amd64 x86_64 Debian 11.2 ext4
# Hostname: hwsrv-890039.nostalgicmail.com
auth_debug = yes
auth_debug_passwords = yes
auth_mechanisms = plain login
auth_verbose = yes
auth_verbose_passwords = plain
debug_log_path = /var/log/dovecot_debug.log
first_valid_uid = 100
info_log_path = /var/log/dovecot_info.log
log_path = /var/log/dovecot_error_warnings.log
mail_gid = mail
mail_location = maildir:/var/vmail/%d/%u
mail_privileged_group = mail
mail_uid = vmail
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    special_use = \Trash
  }
  prefix =
}
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
postmaster_address = postmaster@nostalgicmail.com
protocols = " imap lmtp"
service auth-worker {
  user = vmail
}
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0666
    user = postfix
  }
  unix_listener auth-userdb {
    mode = 0600
    user = vmail
  }
  user = dovecot
}
service lmtp {
  unix_listener lmtp {
    group = postfix
    mode = 0666
    user = postfix
  }
}
ssl_cert = </etc/letsencrypt/live/nostalgicmail.com/cert.pem
ssl_client_ca_dir = /etc/ssl/certs
ssl_dh = # hidden, use -P to show it
ssl_key = # hidden, use -P to show it
userdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
verbose_ssl = yes
zion@hwsrv-890039:~$
</code>```

Postfix looks like so:

```<code>zion@hwsrv-890039:~$ sudo postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
compatibility_level = 2
inet_interfaces = all
inet_protocols = ipv4
mailbox_size_limit = 0
mydestination = localhost
myhostname = hwsrv-890039.nostalgicmail.com
mynetworks = 127.0.0.0/8
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_CApath = /etc/ssl/certs
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_security_level = may
smtpd_use_tls = yes
virtual_alias_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
virtual_transport = lmtp:unix:private/dovecot-lmtp
zion@hwsrv-890039:~$
</code>```

@Andrew Richards
Thanks!  Your reply gave me a lot of information to go on.

(For others facing a similar problem)

I started out by sending grep -rnw '/etc/dovecot' -e 'mail_location' to find all instances of mail_location to make changes there.  Restarted dovecot.service

From there, I still had  Error: stat(/var/vmail/nostalgicmail.com/brad@nostalgicmail.com) errors.  I remember from the documentation that there are SQL queries that use the mailbox locations as well, so I sent  grep -rnw '/etc/dovecot' -e '/var/vmail/%d/%u' to find them. Made corrections, and restarted dovecot.service again.

This cleaned up the first part of my errors, but I still had permissions issues.

```<code>Permission denied (euid=150(<unknown>) egid=8(mail) missing +x perm:
</code>```

The above line tells me that UID 150 is unknown to my system and
dir owned by 2000:2000 mode=0700) tells me who does own the directory.
grep -rnw '/etc/dovecot' -e '150' shows that the SQL string I had is setting a UID for me, so I changed 150 to 2000, restarted dovecot, and it works!  I still wanted to know what user UID 2000 is, so I used
grep -rnw '/etc/dovecot' -e '2000' which happily reported that UID 2000 belongs to user vmail

答:
You state "This is not the correct directory, it should be /var/vmail/nostalgicmail.com/brad". Your (helpfully supplied) config contains,

```<code>mail_location = maildir:/var/vmail/%d/%u
</code>```

Dovecot's mail location variables will render %u as user@domain. Change this to %n, "User part in user@domain" for it to use the path you've mentioned.

You'll may still get the first error though, key part for me,

```<code>...Permission denied (euid=150(<unknown>) egid=8(mail) missing +x perm: /var/vmail/nostalgicmail.com, dir owned by 2000:2000 mode=0700)
</code>```

Assuming the error remains, look up those UIDs in /etc/passwd to see what usernames are involved, then see how that relates to your config, perhaps esp. parts to do with auth. From there you'll likely need to adjust one or more of the Dovecot config, the authentication / mailbox lookup or directory ownership / permissions.

Body:
I have the following error message in the dovecot errors & warnings log after I've tried to rebuild my mail server.

Prior to these errors, I updated my aging system to the latest, and lots of things broke.  The configuration was confetti, so I attempted to rebuild the mail server.  To get this error, I simply login to Roundcube mail.  I'm able to login, however I cant see any emails.

I'm seeing two issues in the error, just not sure how to fix it.

Feb 06 18:07:15 imap(brad@nostalgicmail.com)<96785><ZgOYWl3XtMwX/pCT>: Error: chdir(/var/vmail/nostalgicmail.com/brad@nostalgicmail.com/) failed: Permission denied (euid=150(<unknown>) egid=8(mail) missing +x perm: /var/vmail/nostalgicmail.com, dir owned by 2000:2000 mode=0700)

Feb 06 18:07:15 imap(brad@nostalgicmail.com)<96785><ZgOYWl3XtMwX/pCT>: Error: stat(/var/vmail/nostalgicmail.com/brad@nostalgicmail.com/subscriptions) failed: Permission denied

Issue 1: chdir(/var/vmail/nostalgicmail.com/brad@nostalgicmail.com/)

This is not the correct directory, it should be /var/vmail/nostalgicmail.com/brad

Issue 2: Permission denied (euid=150() egid=8(mail) missing +x perm: /var/vmail/nostalgicmail.com, dir owned by 2000:2000 mode=0700)

This might be fixed after Issue 1 is corrected.

I do have other work to do to complete the server, such as making sure all SSL keys are correct, reintegrating sieve & spamassassin, dkim, spf, and so on.  For now, I just need the email server to function.

My directory setup looks like so:

zion@hwsrv-890039:~$ sudo ls -Al /var/vmail/
total 16
drwx------  5 vmail vmail 4096 Sep 10 19:06 kingmobiletransport.com
drwx------ 11 vmail vmail 4096 Jan 20 18:49 nostalgicmail.com
drwx------  3 vmail vmail 4096 Aug 15 05:28 sites-by-brad.com
drwx------  2 vmail vmail 4096 Feb  5 20:26 spamassassin
zion@hwsrv-890039:~$ sudo ls -Al /var/vmail/nostalgicmail.com/
total 36
drwx------ 4 vmail vmail 4096 Jan 10 19:47 brad
drwx------ 3 vmail vmail 4096 Jan 10 03:59 chronicle
drwx------ 3 vmail vmail 4096 Jul 22  2021 dirtywill
drwx------ 3 vmail vmail 4096 Jul  6  2021 emerald
drwx------ 3 vmail vmail 4096 Jul  6  2021 mickey
drwx------ 3 vmail vmail 4096 Jul  9  2021 mistyblue
drwx------ 4 vmail vmail 4096 Sep 21 20:54 mquin007
drwx------ 3 vmail vmail 4096 Jan 20 18:49 tribeofriche
drwx------ 3 vmail vmail 4096 Jul 29  2021 weather
zion@hwsrv-890039:~$ sudo ls -Al /var/vmail/nostalgicmail.com/brad/
total 12
lrwxrwxrwx  1 vmail vmail   21 Jul  9  2021 .dovecot.sieve -> sieve/roundcube.sieve
-rw-------  1 vmail vmail  726 Jan 10 19:47 .dovecot.svbin
drwx------ 22 vmail vmail 4096 Feb  5 21:57 Maildir
drwx------  3 vmail vmail 4096 Jan 10 19:35 sieve
zion@hwsrv-890039:~$

Dovecot config looks like so:

zion@hwsrv-890039:~$ sudo doveconf -n > dovecot_config
zion@hwsrv-890039:~$ cat dovecot_config
# 2.3.13 (89f716dc2): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.13 (cdd19fe3)
# OS: Linux 5.10.0-11-cloud-amd64 x86_64 Debian 11.2 ext4
# Hostname: hwsrv-890039.nostalgicmail.com
auth_debug = yes
auth_debug_passwords = yes
auth_mechanisms = plain login
auth_verbose = yes
auth_verbose_passwords = plain
debug_log_path = /var/log/dovecot_debug.log
first_valid_uid = 100
info_log_path = /var/log/dovecot_info.log
log_path = /var/log/dovecot_error_warnings.log
mail_gid = mail
mail_location = maildir:/var/vmail/%d/%u
mail_privileged_group = mail
mail_uid = vmail
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    special_use = \Trash
  }
  prefix =
}
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
postmaster_address = postmaster@nostalgicmail.com
protocols = " imap lmtp"
service auth-worker {
  user = vmail
}
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0666
    user = postfix
  }
  unix_listener auth-userdb {
    mode = 0600
    user = vmail
  }
  user = dovecot
}
service lmtp {
  unix_listener lmtp {
    group = postfix
    mode = 0666
    user = postfix
  }
}
ssl_cert = </etc/letsencrypt/live/nostalgicmail.com/cert.pem
ssl_client_ca_dir = /etc/ssl/certs
ssl_dh = # hidden, use -P to show it
ssl_key = # hidden, use -P to show it
userdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
verbose_ssl = yes
zion@hwsrv-890039:~$

Postfix looks like so:

zion@hwsrv-890039:~$ sudo postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
compatibility_level = 2
inet_interfaces = all
inet_protocols = ipv4
mailbox_size_limit = 0
mydestination = localhost
myhostname = hwsrv-890039.nostalgicmail.com
mynetworks = 127.0.0.0/8
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_CApath = /etc/ssl/certs
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_security_level = may
smtpd_use_tls = yes
virtual_alias_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
virtual_transport = lmtp:unix:private/dovecot-lmtp
zion@hwsrv-890039:~$

@Andrew Richards
Thanks!  Your reply gave me a lot of information to go on.

(For others facing a similar problem)

I started out by sending grep -rnw '/etc/dovecot' -e 'mail_location' to find all instances of mail_location to make changes there.  Restarted dovecot.service

From there, I still had  Error: stat(/var/vmail/nostalgicmail.com/brad@nostalgicmail.com) errors.  I remember from the documentation that there are SQL queries that use the mailbox locations as well, so I sent  grep -rnw '/etc/dovecot' -e '/var/vmail/%d/%u' to find them. Made corrections, and restarted dovecot.service again.

This cleaned up the first part of my errors, but I still had permissions issues.

Permission denied (euid=150(<unknown>) egid=8(mail) missing +x perm:

The above line tells me that UID 150 is unknown to my system and
dir owned by 2000:2000 mode=0700) tells me who does own the directory.
grep -rnw '/etc/dovecot' -e '150' shows that the SQL string I had is setting a UID for me, so I changed 150 to 2000, restarted dovecot, and it works!  I still wanted to know what user UID 2000 is, so I used
grep -rnw '/etc/dovecot' -e '2000' which happily reported that UID 2000 belongs to user vmail

Body:
You state "This is not the correct directory, it should be /var/vmail/nostalgicmail.com/brad". Your (helpfully supplied) config contains,

mail_location = maildir:/var/vmail/%d/%u

Dovecot's mail location variables will render %u as user@domain. Change this to %n, "User part in user@domain" for it to use the path you've mentioned.

You'll may still get the first error though, key part for me,

...Permission denied (euid=150(<unknown>) egid=8(mail) missing +x perm: /var/vmail/nostalgicmail.com, dir owned by 2000:2000 mode=0700)

Assuming the error remains, look up those UIDs in /etc/passwd to see what usernames are involved, then see how that relates to your config, perhaps esp. parts to do with auth. From there you'll likely need to adjust one or more of the Dovecot config, the authentication / mailbox lookup or directory ownership / permissions.


问:
Flutter - Logic to create buttons within the app. Gridview, Listview or something else?
I am sorry to ask this question as I am very new to flutter and it may seem like a stupid one. I am trying to create an app that will create buttons at specific positions. I have checked the docs on flutter and could not find anything. Please help only with the logic that needs to be used and I will reasearch the rest. (Any additional help is appreciable). Below are the screenshots of what I want to achieve.

答:
Follow the code-comment for details.

 List<int> data = [];

  ///tap event to increment the grid item
  void onTap() {
    setState(() {
      data.add(3); //random value
    });
  }
 /// adding button
  Widget addButton() {
    return GestureDetector(
      onTap: onTap,
      child: const Icon(
        Icons.add_circle,
        size: 45,
        color: Colors.black,
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: data.isEmpty
          ? Center(
              /// you can use Align widget
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  addButton(),
                  Text("Nothing to show here"),
                ],
              ),
            )
          : GridView.count(
              crossAxisCount: 3,
              crossAxisSpacing: 10,
              mainAxisSpacing: 10,
              children: [
                ...data.map(
                  (e) => InkWell(
                    onTap: () {
                      print(e.toString());
                    },
                    child: Container(
                      color: Colors.deepOrange,
                    ),
                  ),
                ),

                /// add button
                addButton(),
              ],
            ),
    );
  }
```


问:
Rename and delete Room Database
I am wondering how to rename or delete a Room Database which was instantiated by following code:

```<code>AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "database-name").build();
</code>```

Should I expect a database-name.db file in getApplicationContext().getFilesDir(), which I could then rename or delete? Would this approach be safe?

My current workaround would be to use only one database with multiple tables, emulating multiple databases. I am not sure if this approach scales very well though.

I could not find any answers to this question in the documention. I am not asking how to rename or delete columns or rows.

答:
To rename a room database you can do the following when getting your database instance :</p>
```<code>//Kotlin
fun getDatabase(context: Context) : YourRoomDbClass {
   return INSTANCE ?: synchronized(this){
       val dbFile = context.applicationContext.getDatabasePath("your_old_db_name.db")
       if(dbFile.exists()) dbFile.renameTo(File(dbFile.path + "your_new_db_name.db"))
       val instance = Room.databaseBuilder(context.applicationContext, YourRoomDbClass::class.java, "your_new_db_name.db")
                          .build()
       INSTANCE = instance
       instance
   }
}
</code>```

Title: Rename and delete Room Database

Body:
I am wondering how to rename or delete a Room Database which was instantiated by following code:

AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "database-name").build();

Should I expect a database-name.db file in getApplicationContext().getFilesDir(), which I could then rename or delete? Would this approach be safe?

My current workaround would be to use only one database with multiple tables, emulating multiple databases. I am not sure if this approach scales very well though.

I could not find any answers to this question in the documention. I am not asking how to rename or delete columns or rows.

Body:
To rename a room database you can do the following when getting your database instance :

//Kotlin
fun getDatabase(context: Context) : YourRoomDbClass {
   return INSTANCE ?: synchronized(this){
       val dbFile = context.applicationContext.getDatabasePath("your_old_db_name.db")
       if(dbFile.exists()) dbFile.renameTo(File(dbFile.path + "your_new_db_name.db"))
       val instance = Room.databaseBuilder(context.applicationContext, YourRoomDbClass::class.java, "your_new_db_name.db")
                          .build()
       INSTANCE = instance
       instance
   }
}


问:
AttributeError: 'DataFrame' object has no attribute 'operation'
I'm trying to write a function that returns the mean, median, standard deviation, max and min values of a dataset.

Below is my code: it should iterate through every item in the "ops" array and pass them into the "statSummary" function.

The function initalises a list as the operation type (e.g mean/median), performs the operation (calculates mean) and prints the result.

```<code>def statSummary(dataset,operation):
    operation = []
    operation.append(df[dataset].operation())

    return print(operation)

#load dataset
df = pd.read_csv('dataset.csv')

columnNames = list(df.columns)

ops = ["mean","median","std","max","min"]

for i in ops:
    statSummary(columnNames,i)
</code>```

However when trying to run this I recieve the error:

```<code>AttributeError                            Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_8416/4291564190.py in <module>
     30
     31 for i in ops:
---> 32     statSummary(columnNames,i)
     33
     34

~\AppData\Local\Temp/ipykernel_8416/4291564190.py in statSummary(dataset, operation)
     18 def statSummary(dataset,operation):
     19     operation = []
---> 20     operation.append(df[dataset].operation())
     21
     22     return print(operation)

~\anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
   5485         ):
   5486             return self[name]
-> 5487         return object.__getattribute__(self, name)
   5488
   5489     def __setattr__(self, name: str, value) -> None:

AttributeError: 'DataFrame' object has no attribute 'operation'
</code>```

The error seems to be due to ".operation())" on this line

```<code>operation.append(df[dataset].operation())
</code>```

I want to 'plug' the operation variable into this line so I can iterate through my 'ops' list using "'mean','median',std'" etc.

Is this possible?

答:
You're looking for getattr.

```<code>def statSummary(dataset, operation):
    func = getattr(df[dataset], operation)
    return func()  # if `operation` is `"sum"`, this is equivalent to `df[dataset].sum()`.
</code>```

Body:
I'm trying to write a function that returns the mean, median, standard deviation, max and min values of a dataset.

Below is my code: it should iterate through every item in the "ops" array and pass them into the "statSummary" function.

The function initalises a list as the operation type (e.g mean/median), performs the operation (calculates mean) and prints the result.

def statSummary(dataset,operation):
    operation = []
    operation.append(df[dataset].operation())

    return print(operation)

#load dataset
df = pd.read_csv('dataset.csv')

columnNames = list(df.columns)

ops = ["mean","median","std","max","min"]

for i in ops:
    statSummary(columnNames,i)

However when trying to run this I recieve the error:

AttributeError                            Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_8416/4291564190.py in <module>
     30
     31 for i in ops:
---> 32     statSummary(columnNames,i)
     33
     34

~\AppData\Local\Temp/ipykernel_8416/4291564190.py in statSummary(dataset, operation)
     18 def statSummary(dataset,operation):
     19     operation = []
---> 20     operation.append(df[dataset].operation())
     21
     22     return print(operation)

~\anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
   5485         ):
   5486             return self[name]
-> 5487         return object.__getattribute__(self, name)
   5488
   5489     def __setattr__(self, name: str, value) -> None:

AttributeError: 'DataFrame' object has no attribute 'operation'

The error seems to be due to ".operation())" on this line

operation.append(df[dataset].operation())

I want to 'plug' the operation variable into this line so I can iterate through my 'ops' list using "'mean','median',std'" etc.

Is this possible?

Body:
You're looking for getattr.

def statSummary(dataset, operation):
    func = getattr(df[dataset], operation)
    return func()  # if `operation` is `"sum"`, this is equivalent to `df[dataset].sum()`.


问:
Truncate, copy and paste to another sheet - openpyxl
Good day.

"Import" sheet

"Export" sheet

The worksheet logic: one source ip address can ping to different destination ips (e.g. ).

My task: to iterate through the SRC_IP addresses (column=1), eliminate/truncate the duplicates. No need to write one source IP twice in "Export" sheet (for example, in "Import" sheet SRC_IP: 10.115.98.75 was written twice). The single copy of SRC_IP and SRC_RES from "Import" sheet should be copied to "Export" and the related DST_IP should be also copied to "Export" sheet but merged as shown above.

This is what I tried so far.

```<code>import openpyxl
from openpyxl.styles import Alignment

file="C:/data2.xlsx"
wb = openpyxl.load_workbook(file)

ws1=wb.worksheets[0]
ws2=wb.worksheets[1]

ls=[]

for i in ws1.iter_rows(min_row=2, min_col=1, values_only=True):
    ls.append(i)
</code>```

Any ideas?
Thanks.

答:
I found a solution by myself.</p>
```<code>import openpyxl
import math
from openpyxl.styles import Alignment, PatternFill
import collections
class Solution:
  def foo(self):
    file=str(input("File name: "))
    wb = openpyxl.load_workbook(file)
    sh1=str(input("Sheet 1: "))
    sh2=str((input("VLAN to work on: ")))
    if sh2 not in wb.sheetnames:
        wb.create_sheet(sh2)
    c=0 #counter

    ws1=wb[sh1]
    ws2=wb[sh2]

    map={0:0,1:1,2:5,3:6}
    d=collections.defaultdict(list)
    ls=dict()
    ws2.cell(row=1, column=1).value="SRC_IP"
    ws2.cell(row=1, column=2).value="SRC_Name"
    ws2.cell(row=1, column=3).value="DST_IP"
    ws2.cell(row=1, column=4).value="DST_Name"
    ws2.cell(row=1, column=5).value="PROTOCOL"
    ws2.cell(row=1, column=6).value="PORT"

    for rows in ws2.iter_rows(min_row=1, max_row=1, min_col=1, max_col=6):
        for cell in rows:
            cell.fill = PatternFill(start_color='00CCFFFF', end_color='00CCFFFF', fill_type="solid")

    for i,val in enumerate(ws1.iter_rows(min_row=2, min_col=1, values_only=True)):
        if sh2==val[2]:
            if val[5] is None:
                continue
            d[(val[0],val[1])].append((val[5],val[6] or "--Null--",val[11],val[10]))
            print(val)
        else:
            continue

    for (key,value) in d.items():
        if len(value)>=27:
            for i in range(c+2, c+2+math.ceil(len(value)/27)):
                ws2.row_dimensions[i].height=400
            ws2.merge_cells(start_row=c+2, end_row=c+1+math.ceil(len(value)/27), start_column=3, end_column=3) #0+1+2=3 2--3
            ws2.merge_cells(start_row=c+2, end_row=c+1+math.ceil(len(value)/27), start_column=4, end_column=4)
            ws2.merge_cells(start_row=c+2, end_row=c+1+math.ceil(len(value)/27), start_column=5, end_column=5)
            ws2.merge_cells(start_row=c+2, end_row=c+1+math.ceil(len(value)/27), start_column=6, end_column=6)

        ws2.cell(row=c+2, column=1).value=key[0]
        #print(c+2,math.ceil(len(value)/27)+c+1)
        ws2.cell(row=c+2, column=2).value=key[1]
        ws2.cell(row=c+2, column=3).value="\n".join([item[0] for item in value])
        ws2.cell(row=c+2, column=4).value="\n".join([item[1] for item in value])
        ws2.cell(row=c+2, column=5).value="\n".join([item[2] for item in value])
        ws2.cell(row=c+2, column=6).value="\n".join([item[3] for item in value])

        c+=math.ceil(len(value)/27) #c=0 --> 0+2=2 --> c=2

    ws2.alignment=Alignment(wrap_text=True)
    wb.save(file)
    print("Done!")

p=Solution()
p.foo()
</code>```

Body:
Good day.

"Import" sheet

"Export" sheet

The worksheet logic: one source ip address can ping to different destination ips (e.g. ).

My task: to iterate through the SRC_IP addresses (column=1), eliminate/truncate the duplicates. No need to write one source IP twice in "Export" sheet (for example, in "Import" sheet SRC_IP: 10.115.98.75 was written twice). The single copy of SRC_IP and SRC_RES from "Import" sheet should be copied to "Export" and the related DST_IP should be also copied to "Export" sheet but merged as shown above.

This is what I tried so far.

import openpyxl
from openpyxl.styles import Alignment

file="C:/data2.xlsx"
wb = openpyxl.load_workbook(file)

ws1=wb.worksheets[0]
ws2=wb.worksheets[1]

ls=[]

for i in ws1.iter_rows(min_row=2, min_col=1, values_only=True):
    ls.append(i)

Any ideas?
Thanks.

Body:
I found a solution by myself.

import openpyxl
import math
from openpyxl.styles import Alignment, PatternFill
import collections
class Solution:
  def foo(self):
    file=str(input("File name: "))
    wb = openpyxl.load_workbook(file)
    sh1=str(input("Sheet 1: "))
    sh2=str((input("VLAN to work on: ")))
    if sh2 not in wb.sheetnames:
        wb.create_sheet(sh2)
    c=0 #counter

    ws1=wb[sh1]
    ws2=wb[sh2]

    map={0:0,1:1,2:5,3:6}
    d=collections.defaultdict(list)
    ls=dict()
    ws2.cell(row=1, column=1).value="SRC_IP"
    ws2.cell(row=1, column=2).value="SRC_Name"
    ws2.cell(row=1, column=3).value="DST_IP"
    ws2.cell(row=1, column=4).value="DST_Name"
    ws2.cell(row=1, column=5).value="PROTOCOL"
    ws2.cell(row=1, column=6).value="PORT"

    for rows in ws2.iter_rows(min_row=1, max_row=1, min_col=1, max_col=6):
        for cell in rows:
            cell.fill = PatternFill(start_color='00CCFFFF', end_color='00CCFFFF', fill_type="solid")

    for i,val in enumerate(ws1.iter_rows(min_row=2, min_col=1, values_only=True)):
        if sh2==val[2]:
            if val[5] is None:
                continue
            d[(val[0],val[1])].append((val[5],val[6] or "--Null--",val[11],val[10]))
            print(val)
        else:
            continue

    for (key,value) in d.items():
        if len(value)>=27:
            for i in range(c+2, c+2+math.ceil(len(value)/27)):
                ws2.row_dimensions[i].height=400
            ws2.merge_cells(start_row=c+2, end_row=c+1+math.ceil(len(value)/27), start_column=3, end_column=3) #0+1+2=3 2--3
            ws2.merge_cells(start_row=c+2, end_row=c+1+math.ceil(len(value)/27), start_column=4, end_column=4)
            ws2.merge_cells(start_row=c+2, end_row=c+1+math.ceil(len(value)/27), start_column=5, end_column=5)
            ws2.merge_cells(start_row=c+2, end_row=c+1+math.ceil(len(value)/27), start_column=6, end_column=6)

        ws2.cell(row=c+2, column=1).value=key[0]
        #print(c+2,math.ceil(len(value)/27)+c+1)
        ws2.cell(row=c+2, column=2).value=key[1]
        ws2.cell(row=c+2, column=3).value="\n".join([item[0] for item in value])
        ws2.cell(row=c+2, column=4).value="\n".join([item[1] for item in value])
        ws2.cell(row=c+2, column=5).value="\n".join([item[2] for item in value])
        ws2.cell(row=c+2, column=6).value="\n".join([item[3] for item in value])

        c+=math.ceil(len(value)/27) #c=0 --> 0+2=2 --> c=2

    ws2.alignment=Alignment(wrap_text=True)
    wb.save(file)
    print("Done!")

p=Solution()
p.foo()


问:
Accesing superclass attribute during subclass construction in Python
Is it possible to access superclass's attributes during class construction?
Here's my code:

```<code>class A:
   x = 1

class B(A):
   x += 1   # <- error
</code>```

The increment line x += ... is not valid, because x is not defined at this moment. You may suggest doing it in __init__, but I need to initialize the values before the constructor and want to minimize the code.

The code x = A.x + 1 will not work in my case because the A is generated in run-time. So the real code for B looks like

```<code>class A:
  x: int

def class_gen(params):
  class SubA(A):
    x = 1
  return SubA

class B(class_gen(some_params)):
  x += 1
</code>```

I've found a weird workaround:
x = A.__subclasses__()[-1].x + 1 (indeed the last subclass of A will be the generated super), but it looks too dirty and unstable.

Another workaround is declaring the a 'stub' class variable:

```<code>...
_Stub = class_gen(some_params)
class B(_Stub):
  x = _Stub.x + 1
</code>```

but is it also looks urgly. Is there a better way for a perfectionist?

答:
I think you can accomplish it by using __new__ in the subclass.

```<code>class A:
    x = 1

class B(A):
    def __new__(cls, *args, **kwargs):
        cls.x += 1
        return super().__new__(cls, *args, **kwargs)

b = B()
print(b.x)  # 2
</code>```

Body:
Is it possible to access superclass's attributes during class construction?
Here's my code:

class A:
   x = 1

class B(A):
   x += 1   # <- error

The increment line x += ... is not valid, because x is not defined at this moment. You may suggest doing it in __init__, but I need to initialize the values before the constructor and want to minimize the code.

The code x = A.x + 1 will not work in my case because the A is generated in run-time. So the real code for B looks like

class A:
  x: int

def class_gen(params):
  class SubA(A):
    x = 1
  return SubA

class B(class_gen(some_params)):
  x += 1

I've found a weird workaround:
x = A.__subclasses__()[-1].x + 1 (indeed the last subclass of A will be the generated super), but it looks too dirty and unstable.

Another workaround is declaring the a 'stub' class variable:

...
_Stub = class_gen(some_params)
class B(_Stub):
  x = _Stub.x + 1

but is it also looks urgly. Is there a better way for a perfectionist?

Body:
I think you can accomplish it by using __new__ in the subclass.

class A:
    x = 1

class B(A):
    def __new__(cls, *args, **kwargs):
        cls.x += 1
        return super().__new__(cls, *args, **kwargs)

b = B()
print(b.x)  # 2


问:
I am trying to get TimeZones from an API in flutter but due to some reason its not returning all timeZones
I am new to the flutter framework. I am trying to get TimeZones from an API in flutter but due to some reason, it's not returning all timeZones. URL from which I am trying to get a response is: https://www.timeapi.io/api/TimeZone/AvailableTimeZones

Here is my code :

```<code>import 'package:http/http.dart';
import 'dart:convert';

class WorldClock {
  late String location;
  late String time;
  late String flag;
  late String url;
  late bool isDayTime = false;

  WorldClock({required this.location, required this.flag, required this.url});

  Future<void> getLocations() async {
    try {
      Response response = await get(
          Uri.parse('https://www.timeapi.io/api/TimeZone/AvailableTimeZones'));
      print(response.body);
    } catch (e) {
      print('failed to load locations');
    }
  }
</code>```

The output I am getting is :

["Africa/Abidjan","Africa/Accra","Africa/Addis_Ababa","Africa/Algiers","Africa/Asmara","Africa/Asmera","Africa/Bamako","Africa/Bangui","Africa/Banjul","Africa/Bissau","Africa/Blantyre","Africa/Brazzaville","Africa/Bujumbura","Africa/Cairo","Africa/Casablanca","Africa/Ceuta","Africa/Conakry","Africa/Dakar","Africa/Dar_es_Salaam","Africa/Djibouti","Africa/Douala","Africa/El_Aaiun","Africa/Freetown","Africa/Gaborone","Africa/Harare","Africa/Johannesburg","Africa/Juba","Africa/Kampala","Africa/Khartoum","Africa/Kigali","Africa/Kinshasa","Africa/Lagos","Africa/Libreville","Africa/Lome","Africa/Luanda","Africa/Lubumbashi","Africa/Lusaka","Africa/Malabo","Africa/Maputo","Africa/Maseru","Africa/Mbabane","Africa/Mogadishu","Africa/Monrovia","Africa/Nairobi","Africa/Ndjamena","Africa/Niamey","Africa/Nouakchott","Africa/Ouagadougou","Africa/Porto-Novo","Africa/Sao_Tome","Africa/Timbuktu","Africa/Tripoli","Africa/Tunis","Africa/Windhoek","America/Adak","America/Anchorage","America/Anguilla","America/Antigua","America/Ar

From the output, you can clearly see after Ameria/Ar, it's breaking and not storing it.

Any possible fix?

答:
Every ide has a max console log limit, you can change these limits.

If you are using IntelliJ or Android Studio IDE follow below link;
https://stackoverflow.com/a/66744625/13109852

or using VSCode follow below link;
https://stackoverflow.com/a/63013785/13109852

Body:
I am new to the flutter framework. I am trying to get TimeZones from an API in flutter but due to some reason, it's not returning all timeZones. URL from which I am trying to get a response is: https://www.timeapi.io/api/TimeZone/AvailableTimeZones

Here is my code :

import 'package:http/http.dart';
import 'dart:convert';

class WorldClock {
  late String location;
  late String time;
  late String flag;
  late String url;
  late bool isDayTime = false;

  WorldClock({required this.location, required this.flag, required this.url});

  Future<void> getLocations() async {
    try {
      Response response = await get(
          Uri.parse('https://www.timeapi.io/api/TimeZone/AvailableTimeZones'));
      print(response.body);
    } catch (e) {
      print('failed to load locations');
    }
  }

The output I am getting is :

["Africa/Abidjan","Africa/Accra","Africa/Addis_Ababa","Africa/Algiers","Africa/Asmara","Africa/Asmera","Africa/Bamako","Africa/Bangui","Africa/Banjul","Africa/Bissau","Africa/Blantyre","Africa/Brazzaville","Africa/Bujumbura","Africa/Cairo","Africa/Casablanca","Africa/Ceuta","Africa/Conakry","Africa/Dakar","Africa/Dar_es_Salaam","Africa/Djibouti","Africa/Douala","Africa/El_Aaiun","Africa/Freetown","Africa/Gaborone","Africa/Harare","Africa/Johannesburg","Africa/Juba","Africa/Kampala","Africa/Khartoum","Africa/Kigali","Africa/Kinshasa","Africa/Lagos","Africa/Libreville","Africa/Lome","Africa/Luanda","Africa/Lubumbashi","Africa/Lusaka","Africa/Malabo","Africa/Maputo","Africa/Maseru","Africa/Mbabane","Africa/Mogadishu","Africa/Monrovia","Africa/Nairobi","Africa/Ndjamena","Africa/Niamey","Africa/Nouakchott","Africa/Ouagadougou","Africa/Porto-Novo","Africa/Sao_Tome","Africa/Timbuktu","Africa/Tripoli","Africa/Tunis","Africa/Windhoek","America/Adak","America/Anchorage","America/Anguilla","America/Antigua","America/Ar

From the output, you can clearly see after Ameria/Ar, it's breaking and not storing it.

Any possible fix?


问:
Shell Script to SSH to Multiple Remote Machines and Leave a Command Running
I'm coding a distributed application and I need to spawn some process in multiple machines using ssh. The problem is that this command blocks the terminal, so I need that this command runs as a process. So that I can continue giving commands and moving to another machines.

For example

the command is something like:

make run
```
<p>this command blocks my terminal, but I want to ssh to another machine and run this command, and another commands.</p>
<p>For now I'm with this script that is not working:</p>
<pre class="lang-sh prettyprint-override"><code>#!/bin/bash

HOSTS=(ex1 ex2)
COMPILE_SCRIPT="make"
RUN_CHEFS="make run &"
CLIENT_SCRIPT="make client"

# Compile the project
ssh "${HOSTS[0]}" "${COMPILE_SCRIPT}"

# Run the command in the hosts
for HOSTNAME in ${HOSTS[*]} ; do
  ssh "${HOSTNAME}" "${RUN_CHEFS}"
done

ssh "${HOSTS[0]}" "${CLIENT_SCRIPT}"

</code>```

答:
One option you have is to use a utility such as mussh, which lets you do things like:

```<code>mussh -l username -m -h host1 host2 host3 -c "make run"
</code>```

-m flag means run concurrently.

Body:
I'm coding a distributed application and I need to spawn some process in multiple machines using ssh. The problem is that this command blocks the terminal, so I need that this command runs as a process. So that I can continue giving commands and moving to another machines.

For example

the command is something like:

make run

this command blocks my terminal, but I want to ssh to another machine and run this command, and another commands.

For now I'm with this script that is not working:

#!/bin/bash

HOSTS=(ex1 ex2)
COMPILE_SCRIPT="make"
RUN_CHEFS="make run &"
CLIENT_SCRIPT="make client"

# Compile the project
ssh "${HOSTS[0]}" "${COMPILE_SCRIPT}"

# Run the command in the hosts
for HOSTNAME in ${HOSTS[*]} ; do
  ssh "${HOSTNAME}" "${RUN_CHEFS}"
done

ssh "${HOSTS[0]}" "${CLIENT_SCRIPT}"

Body:
One option you have is to use a utility such as mussh, which lets you do things like:

mussh -l username -m -h host1 host2 host3 -c "make run"

-m flag means run concurrently.


问:
How to detect contrast index of a photo?
I'm trying to take a group of photos (with the addition that more photos can be added after), and try to find a contrast/brightness/saturation index that I can use to sort the photos. Brightness and saturation is pretty easy, but I'm stuck with finding the contrast. I've tried several things (average of difference of all pixels with their neighbors, or splitting into 16 zones (4x4) and averaging difference of their averages, to fight against noise's added contrast in the previous method) but nothing gives me accurate results. My meaning of the contrast term is nothing technical/scientific, just visually high or low contrast, the one that you look by your eye and say. I am no expert of math or signal processing, and I'm looking for a simple and straightforward algorithm, if any. How do I get an overall numeric contrast index/ratio/value/whatever (as long as it can be used to sort photos) of an image?

答:
You could try to make a histogram of pixel brightness. For "ideal" contrast image it should be uniform. And deviation from the uniformity could be quantity of contrast.

For more details, see histogram equalization method of contrast enhancing:
http://en.wikipedia.org/wiki/Histogram_equalization