Tag Archives: Python3

Python 3: How to Solve Demjson Install Error

The following error occurs when Python 3 installs demjson 2.2.4

error in demjson setup command: use_2to3 is invalid

Since demjson 2.2.4 is compatible with python2 and python3, some code needs to be converted when the installation environment is python3

Setuptools no longer supports 2to3 builds from version 58.0.0, so demjson 2.2.4 is no longer available after installation,

It can be solved by demoting the version of setuptools

pip install --upgrade setuptools==57.5.0

[Solved] Python 3 installation pilot error: Building wheel for pillow (setup.py) … error

Foreword

Recently, the pilot library will be used to train the verification code model, but it can’t be installed alive or dead

Environment

Installed in docker, python3

Try to install

pip install pillow

easy_install Pillow

pipenv install pillow

As a result, life and death just can’t fit it

Errors are reported as follows:

Collecting pillow
  Using cached https://files.pythonhosted.org/packages/5b/bb/cdc8086db1f15d0664dd22a62c69613cdc00f1dd430b5b19df1bea83f2a3/Pillow-6.2.1.tar.gz
Building wheels for collected packages: pillow
  Building wheel for pillow (setup.py) ... error
  ERROR: Complete output from command /usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-1vq2qpq_/pillow/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-heq42z9x --python-tag cp37:
  ERROR: running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.7
  creating build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/PngImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/PaletteFile.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/WalImageFile.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImagePath.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/MspImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/GifImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/SpiderImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/FliImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/CurImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/MpoImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/McIdasImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/PsdImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/IptcImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/XbmImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/DcxImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ExifTags.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/FontFile.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/TiffTags.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/MpegImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/GimpPaletteFile.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/PyAccess.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageFile.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ContainerIO.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageColor.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/IcoImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/Image.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/JpegPresets.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageOps.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/Hdf5StubImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/PcdImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageStat.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageShow.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/PdfImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/XpmImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImagePalette.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/MicImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/_util.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageMorph.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/FtexImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/GbrImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageDraw.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/BufrStubImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/PSDraw.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageDraw2.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/TarIO.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/FitsStubImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/_binary.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/TgaImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageQt.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/PpmImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/PcfFontFile.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageTk.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/features.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/JpegImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageCms.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageGrab.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/SunImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/WebPImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageFilter.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/FpxImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageTransform.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/GdImageFile.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/__init__.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageMath.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/_version.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageSequence.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/__main__.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/PalmImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/PcxImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/WmfImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/DdsImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/IcnsImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/SgiImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/BlpImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/Jpeg2KImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageEnhance.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageFont.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/TiffImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageWin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageMode.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/ImageChops.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/PdfParser.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/GribStubImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/GimpGradientFile.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/_tkinter_finder.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/XVThumbImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
  copying src/PIL/BdfFontFile.py -> build/lib.linux-x86_64-3.7/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 '.coveragerc'
  warning: no previously-included files found matching '.codecov.yml'
  warning: no previously-included files found matching '.editorconfig'
  warning: no previously-included files found matching '.readthedocs.yml'
  warning: no previously-included files found matching 'azure-pipelines.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 '.azure-pipelines'
  no previously-included directories found matching '.travis'
  writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
  running build_ext
  
  
  The headers or library files could not be found for jpeg,
  a required dependency when compiling Pillow from source.
  
  Please see the install instructions at:
     https://pillow.readthedocs.io/en/latest/installation.html
  
  Traceback (most recent call last):
    File "/tmp/pip-install-1vq2qpq_/pillow/setup.py", line 888, in <module>
      zip_safe=not (debug_build() or PLATFORM_MINGW),
    File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
      return distutils.core.setup(**attrs)
    File "/usr/local/lib/python3.7/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/local/lib/python3.7/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 192, in run
      self.run_command('build')
    File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.7/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.7/distutils/command/build_ext.py", line 340, in run
      self.build_extensions()
    File "/tmp/pip-install-1vq2qpq_/pillow/setup.py", line 687, in build_extensions
      raise RequiredDependencyException(f)
  __main__.RequiredDependencyException: jpeg
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-1vq2qpq_/pillow/setup.py", line 903, in <module>
      raise RequiredDependencyException(msg)
  __main__.RequiredDependencyException:
  
  The headers or library files could not be found for jpeg,
  a required dependency when compiling Pillow from source.
  
  Please see the install instructions at:
     https://pillow.readthedocs.io/en/latest/installation.html
  
  
  ----------------------------------------
  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: Complete output from command /usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-1vq2qpq_/pillow/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-3r__g4ou/install-record.txt --single-version-externally-managed --compile:
    ERROR: running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/PngImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/PaletteFile.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/WalImageFile.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImagePath.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/MspImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/GifImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/SpiderImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/FliImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/CurImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/MpoImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/McIdasImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/PsdImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/IptcImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/XbmImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/DcxImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ExifTags.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/FontFile.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/TiffTags.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/MpegImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/GimpPaletteFile.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/PyAccess.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageFile.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ContainerIO.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageColor.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/IcoImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/Image.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/JpegPresets.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageOps.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/Hdf5StubImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/PcdImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageStat.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageShow.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/PdfImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/XpmImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImagePalette.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/MicImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/_util.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageMorph.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/FtexImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/GbrImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageDraw.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/BufrStubImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/PSDraw.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageDraw2.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/TarIO.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/FitsStubImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/_binary.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/TgaImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageQt.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/PpmImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/PcfFontFile.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageTk.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/features.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/JpegImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageCms.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageGrab.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/SunImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/WebPImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageFilter.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/FpxImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageTransform.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/GdImageFile.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/__init__.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageMath.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/_version.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageSequence.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/__main__.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/PalmImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/PcxImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/WmfImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/DdsImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/IcnsImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/SgiImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/BlpImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/Jpeg2KImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageEnhance.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageFont.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/TiffImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageWin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageMode.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/ImageChops.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/PdfParser.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/GribStubImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/GimpGradientFile.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/_tkinter_finder.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/XVThumbImagePlugin.py -> build/lib.linux-x86_64-3.7/PIL
    copying src/PIL/BdfFontFile.py -> build/lib.linux-x86_64-3.7/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 '.coveragerc'
    warning: no previously-included files found matching '.codecov.yml'
    warning: no previously-included files found matching '.editorconfig'
    warning: no previously-included files found matching '.readthedocs.yml'
    warning: no previously-included files found matching 'azure-pipelines.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 '.azure-pipelines'
    no previously-included directories found matching '.travis'
    writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
    running build_ext
    
    
    The headers or library files could not be found for jpeg,
    a required dependency when compiling Pillow from source.
    
    Please see the install instructions at:
       https://pillow.readthedocs.io/en/latest/installation.html
    
    Traceback (most recent call last):
      File "/tmp/pip-install-1vq2qpq_/pillow/setup.py", line 888, in <module>
        zip_safe=not (debug_build() or PLATFORM_MINGW),
      File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/usr/local/lib/python3.7/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/local/lib/python3.7/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python3.7/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/local/lib/python3.7/distutils/command/install.py", line 545, in run
        self.run_command('build')
      File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python3.7/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python3.7/distutils/command/build_ext.py", line 340, in run
        self.build_extensions()
      File "/tmp/pip-install-1vq2qpq_/pillow/setup.py", line 687, in build_extensions
        raise RequiredDependencyException(f)
    __main__.RequiredDependencyException: jpeg
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-1vq2qpq_/pillow/setup.py", line 903, in <module>
        raise RequiredDependencyException(msg)
    __main__.RequiredDependencyException:
    
    The headers or library files could not be found for jpeg,
    a required dependency when compiling Pillow from source.
    
    Please see the install instructions at:
       https://pillow.readthedocs.io/en/latest/installation.html
    
    
    ----------------------------------------
ERROR: Command "/usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-1vq2qpq_/pillow/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-3r__g4ou/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-1vq2qpq_/pillow/

 

Solving

I searched hard on the Internet and finally found the answer in stack overflow. It turned out that there was a lack of dependency package

https://stackoverflow.com/questions/44043906/the-headers-or-library-files-could-not-be-found-for-jpeg-installing-pillow-on/44044479#44044479

Solution

In build   Add the following contents to the dockerfile file:

FROM python:alpine
RUN apk --update add libxml2-dev libxslt-dev libffi-dev gcc musl-dev libgcc openssl-dev curl
RUN apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev
RUN pip install Pillow

So you can build successfully

You can enter the container

Install these dependencies directly, and then you can install them directly in the container without rebuilding the image

apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev

 

Supplement

Well, you can use it happily. Others may be permission errors, or switch to the installation source

Python3 Use urlliburlopen error EOF occurred in violation of protocol (_ssl.c:841)

python3:

import urllib.request
from bs4 import BeautifulSoup

response = urllib.request.urlopen("http://php.net/")
html = response.read()
soup=BeautifulSoup(html, "html5lib")
text=soup.get_text(strip=True)
print(text)

The code is very simple, just grabbing http://php.net/ Page text content, and then use the beautifulsoup module to clear and filter out redundant HTML tags. It seems that the permission was successful for the first time, and then stuck all the time and reported an error again:

File "C:\Python36\lib\urllib\request.py", line 504, in _call_chain
    result = func(*args)
  File "C:\Python36\lib\urllib\request.py", line 1361, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "C:\Python36\lib\urllib\request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error EOF occurred in violation of protocol (_ssl.c:841)>

In fact, Google browser is accessible

This problem may be due to the fact that sslv2 is disabled on the web server, and the older Python library Python 2. X tries to work with protocol by default_ Sslv23 establishes the connection. Therefore, in this case, you need to select the SSL version that you want to use

To change the SSL version used in HTTPS, you need to subclass the httpadapter class and mount it to the session object. For example, if you want to force the use of tlsv1, the new transport adapter will look like this:

from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager

class MyAdapter(HTTPAdapter):
    def init_poolmanager(self, connections, maxsize, block=False):
        self.poolmanager = PoolManager(num_pools=connections,
                                       maxsize=maxsize,
                                       block=block,
                                       ssl_version=ssl.PROTOCOL_TLSv1)

Then, you can mount it to the requests session object:

s=requests.Session()
s.mount('https://', MyAdapter())
response = urllib.request.urlopen("http://php.net/")

It’s easy to write a universal transport adapter, which can get any SSL type from the package in the SSL constructor and use it

from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager

class SSLAdapter(HTTPAdapter):
    '''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''
    def __init__(self, ssl_version=None, **kwargs):
        self.ssl_version = ssl_version

        super(SSLAdapter, self).__init__(**kwargs)

    def init_poolmanager(self, connections, maxsize, block=False):
        self.poolmanager = PoolManager(num_pools=connections,
                                       maxsize=maxsize,
                                       block=block,
                                       ssl_version=self.ssl_version)

The above error code after modification:

import urllib.request
from bs4 import BeautifulSoup
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager
import ssl

class MyAdapter(HTTPAdapter):
    def init_poolmanager(self, connections, maxsize, block=False):
        self.poolmanager = PoolManager(num_pools=connections,
                                       maxsize=maxsize,
                                       block=block,
                                       ssl_version=ssl.PROTOCOL_TLSv1)

s=requests.Session()
s.mount('https://', MyAdapter())
response = urllib.request.urlopen("http://php.net/")
html = response.read()
soup=BeautifulSoup(html, "html5lib")
text=soup.get_text(strip=True)
print(text)

It can capture web page text information normally

Unable to return file stream in Python 3, uwsgi report error

Why can’t you stop buying 618?From the technical dimension to explore>>>

Questions

In the python 3 environment, when the web returns a file stream (for example, Django returns fileresponse), it will find that the client has not received any return, and the download will prompt a network error

Check the uwsgi log and find that the error is as follows:

io.UnsupportedOperation: fileno

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 156, in __call__
    response = environ['wsgi.file_wrapper'](response.file_to_stream)
SystemError: <built-in function uwsgi_sendfile> returned a result with an error set

Solution

Method 1

Add the -- WSGI disable file wrapper = true option to the uwsgi startup configuration, and then restart

https://github.com/unbit/uwsgi/issues/1126

https://uwsgi-docs.readthedocs.io/en/latest/Changelog-2.0.12.html#wsgi -disable-file-wrapper

Method 2

Use other ways to download, such as uploading to alicloud, qiniu, etc., and return to the download address to download

Using pyenv causes the problem that python3 cannot import SQLite3

Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>

Questions

I want to install a jupyter to use the functions of notebook. However, when I execute jupyter notebook , I report an error directly

ModuleNotFoundError: No module named '_sqlite3'

Strange, isn’t python3 supported by SQLite3?Solution

Looking at the mistakes, I remember that my Linux version of Python is managed by pyenv, so now 3.7.4 is actually installed by pyenv install 3.7.4 . Pyenv installation, in fact, is to download the source code from the official website to compile and install, so think of it, is it difficult because the SQLite3 development package is not installed

Try to execute sudo apt install libsqlite3 dev , and it is not installed

After the installation is completed, you can go over pyenv install 3.7.4 , ask if you want to re install it, then download the source code from the official website and compile it. It takes about 10 minutes to compile, execute Import SQLite3 , and it’s OK

Postscript

It seems that pyenv also has trouble managing python. After that, I don’t know how many functions are available because it doesn’t have any dependencies installed, so it doesn’t turn on this feature directly

How to use htmltestrunner.py to report importerror: no module named ‘stringio’ in Python 3

How to use htmltestrunner.py to report importerror: no module named ‘stringio’ in python3

1. The reason is that the official website is written in python2 syntax, and the official manually changes the official website’s htmltestrunner.py to python3 syntax: 

 

2. Modification summary: 

Line 94, change import stringio to import io

Line 539, change self. Outputbuffer = stringio. Stringio() to self. Outputbuffer = io. Stringio ()

On line 642, change if not rmap. Has_ Key (CLS): modify to if not CLS in rmap:

In line 766, change uo = O. code (‘latin-1 ‘) to uo = E

In line 772 (775 if not found), change UE = E. decode (‘latin-1 ‘) to UE = E

On line 631, print & gt> Sys. Stderr, ‘\ ntime elapsed% s’% (self. StopTime self. Starttime) is modified to print (sys. Stderr,’ \ ntime elapsed% s’% (self. StopTime self. Starttime))

Typeerror: write() argument must be STR, not bytes+

There is a problem with the file opening method. If you change the previous opening statement to binary mode, there is no problem

fo = open("temp.txt", "wb+")  #Change 'w' to 'wb+'

Python3: list dict set [UNK]unhashable type

 

code

coder@ubuntu:~$ source activate py37
(py37) coder@ubuntu:~$ ipython
Python 3.7.3 (default, Mar 27 2019, 22:11:17) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: hash(list())                                                            
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-3e2eb619e4e4> in <module>
----> 1 hash(list())

TypeError: unhashable type: 'list'

In [2]: hash(dict())                                                            
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-7762fff637c6> in <module>
----> 1 hash(dict())

TypeError: unhashable type: 'dict'

In [3]: hash(set())                                                             
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-2699417ebeac> in <module>
----> 1 hash(set())

TypeError: unhashable type: 'set'

In [4]: exit                                                                    
(py37) coder@ubuntu:~$ conda deactivate
coder@ubuntu:~$ 

source_code

def hash(*args, **kwargs): # real signature unknown
    """
    Return the hash value for the given object.
    
    Two objects that compare equal must also have the same hash value, but the
    reverse is not necessarily true.
    """
    pass

 

python3 are installed through pip on Win 10, Unicode decodeerror: ‘UTF-8’ codec can’t decode byte

UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xd5 in position 2: invalid continuation byte

when installing Python3 via pip on Win10
I encountered UnicodeDecodeError when installing via pip.

The system is windows 10 and the python version is 3.6.0.

The complete message is as follows.

C:\Windows\system32>pip install SQLAlchemy
Collecting SQLAlchemy
  Using cached SQLAlchemy-1.1.4.tar.gz
Installing collected packages: SQLAlchemy
  Running setup.py install for SQLAlchemy ... error
Exception:
Traceback (most recent call last):
  File "c:\program files\python36\lib\site-packages\pip\compat\__init__.py", line 73, in console_to_str
    return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 34: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\program files\python36\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\program files\python36\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "c:\program files\python36\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "c:\program files\python36\lib\site-packages\pip\req\req_install.py", line 878, in install
    spinner=spinner,
  File "c:\program files\python36\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "c:\program files\python36\lib\site-packages\pip\compat\__init__.py", line 75, in console_to_str
    return s.decode('utf_8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 34: invalid start byte

I’ve tried to modify the code page with “CHCP 65001”, but it didn’t work. I have tried the method of “CHCP 866”, but it has no effect

I also found many ways to use sys. Set default encoding in various places, but I used Python 3

Update:

I saw on stackoverflow that it is suggested to modify the code page to 437. It is not only the above problem… But also the permissionerror: [winerror 32] another program is using this file and the process cannot access it

The error information is as follows:

C:\Users\59740>pip install SQLAlchemy
Collecting SQLAlchemy
  Using cached SQLAlchemy-1.1.4.tar.gz
Installing collected packages: SQLAlchemy
  Running setup.py install for SQLAlchemy ... error
Exception:
Traceback (most recent call last):
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\compat\__init__.py", line 73, in console_to_str
    return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 34: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_install.py", line 878, in install
    spinner=spinner,
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\compat\__init__.py", line 75, in console_to_str
    return s.decode('utf_8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 34: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\commands\install.py", line 385, in run
    requirement_set.cleanup_files()
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_set.py", line 729, in cleanup_files
    req.remove_temporary_source()
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_install.py", line 977, in remove_temporary_sou
    rmtree(self.source_dir)
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\retrying.py", line 212, in call
    raise attempt.get()
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\six.py", line 686, in reraise
    raise value
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\utils\__init__.py", line 102, in rmtree
    onerror=rmtree_errorhandler)
  File "c:\users\59740\appdata\local\programs\python\python36\lib\shutil.py", line 488, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "c:\users\59740\appdata\local\programs\python\python36\lib\shutil.py", line 387, in _rmtree_unsafe
    onerror(os.rmdir, path, sys.exc_info())
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\utils\__init__.py", line 114, in rmtree_errorhandler
    func(path)
PermissionError: [WinError 32] Another program is using this file and the process cannot access it. : 'C:\\Users\\59740\\AppData\\Local\\Temp\\pip-build-1djzmudb\\SQLAlchemy'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\commands\install.py", line 385, in run
    requirement_set.cleanup_files()
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\utils\build.py", line 38, in __exit__
    self.cleanup()
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\utils\build.py", line 42, in cleanup
    rmtree(self.name)
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\retrying.py", line 212, in call
    raise attempt.get()
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\six.py", line 686, in reraise
    raise value
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\utils\__init__.py", line 102, in rmtree
    onerror=rmtree_errorhandler)
  File "c:\users\59740\appdata\local\programs\python\python36\lib\shutil.py", line 488, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "c:\users\59740\appdata\local\programs\python\python36\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "c:\users\59740\appdata\local\programs\python\python36\lib\shutil.py", line 387, in _rmtree_unsafe
    onerror(os.rmdir, path, sys.exc_info())
  File "c:\users\59740\appdata\local\programs\python\python36\lib\site-packages\pip\utils\__init__.py", line 114, in rmtree_errorhandler
    func(path)
PermissionError: [WinError 32] Another program is using this file and the process cannot access it. : 'C:\\Users\\59740\\AppData\\Local\\Temp\\pip-build-1djzmudb\\SQLAlchemy'

Solution:

Open
C: (program files \ \ python36 \ \ lib \ \ site packages \ \ PIP \ \ compat\__ init__. Py about 75 lines
return s.decode ('utf_ 8 ') to return s.decode ('cp936')

Reason:
coding problem, although PY3 uses UTF-8. But the terminal display under win still uses GBK code