python异常处理时报错,提示:HTTPError: HTTP Error 404: Not Found

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python异常处理时报错,提示:HTTPError: HTTP Error 404: Not Found相关的知识,希望对你有一定的参考价值。

import urllib.request

url='https://t1.onvshen.com:85/gallery/26120/26667/s/001.jpg1'

try:
url=urllib.request.urlopen(url)
except HTTPError as e:
print("the server cannot fulfill the request")
print("Error code:",e.code)
except URLError as e:
print("we failed to reach a server")
print("reason:",e.reason)
else:
print('it is fine')

参考技术A url='https://t1.onvshen.com:85/gallery/26120/26667/s/001.jpg' #后面多了一个1

win10下pip3安装tesserocr时报错

使用pip3在线安装tesserocr时报错,刚开始报错内容是提示未安装vs2014,安装完以后报错内容如下

ERROR: Command errored out with exit status 1:
     command: ‘c:\users\administrator\appdata\local\programs\python\python37\python.exe‘ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"‘"‘C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-v4ys64lr\\tesserocr\\setup.py‘"‘"‘; __file__=‘"‘"‘C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-v4ys64lr\\tesserocr\\setup.py‘"‘"‘;f=getattr(tokenize, ‘"‘"‘open‘"‘"‘, open)(__file__);code=f.read().replace(‘"‘"‘\r\n‘"‘"‘, ‘"‘"‘\n‘"‘"‘);f.close();exec(compile(code, __file__, ‘"‘"‘exec‘"‘"‘))‘ install --record ‘C:\Users\ADMINI~1\AppData\Local\Temp\pip-record-znybe2k0\install-record.txt‘ --single-version-externally-managed --compile
         cwd: C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-v4ys64lr\tesserocr    Complete output (18 lines):
    C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-v4ys64lr\tesserocr\setup.py:134: DeprecationWarning: The ‘warn‘ method is deprecated, use ‘warning‘ instead
      _LOGGER.warn(‘Failed to extract tesseract version from executable: ‘.format(e))
    Failed to extract tesseract version from executable: [WinError 2] 系统找不到指定的文件。
    Supporting tesseract v3.04.00
    Building with configs: ‘libraries‘: [‘tesseract‘, ‘lept‘], ‘cython_compile_time_env‘: ‘TESSERACT_VERSION‘: 50593792
    c:\users\administrator\appdata\local\programs\python\python37\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: ‘long_description_content_type‘
      warnings.warn(msg)
    running install
    running build
    running build_ext
    building ‘tesserocr‘ extension
    creating build
    creating build\temp.win-amd64-3.7
    creating build\temp.win-amd64-3.7\Release
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\administrator\appdata\local\programs\python\python37\include -Ic:\users\administrator\appdata\local\programs\python\python37\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" /EHsc /Tptesserocr.cpp /Fobuild\temp.win-amd64-3.7\Release\tesserocr.obj
    tesserocr.cpp
    c:\users\administrator\appdata\local\programs\python\python37\include\pyconfig.h(215): fatal error C1083: Cannot open include file: ‘basetsd.h‘: No such file or directory
    error: command ‘C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe‘ failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: ‘c:\users\administrator\appdata\local\programs\python\python37\python.exe‘ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"‘"‘C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-v4ys64lr\\tesserocr\\setup.py‘"‘"‘; __file__=‘"‘"‘C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-v4ys64lr\\tesserocr\\setup.py‘"‘"‘;f=getattr(tokenize, ‘"‘"‘open‘"‘"‘, open)(__file__);code=f.read().replace(‘"‘"‘\r\n‘"‘"‘, ‘"‘"‘\n‘"‘"‘);f.close();exec(compile(code, __file__, ‘"‘"‘exec‘"‘"‘))‘ install --record ‘C:\Users\ADMINI~1\AppData\Local\Temp\pip-record-znybe2k0\install-record.txt‘ --single-version-externally-managed --compile Check the logs for full command output.

  目前没找到其他比较好的解决办法,只能下载离线包后手动pip3安装,

下载地址:https://github.com/simonflueckiger/tesserocr-windows_build/releases

 

以上是关于python异常处理时报错,提示:HTTPError: HTTP Error 404: Not Found的主要内容,如果未能解决你的问题,请参考以下文章

Java 在使用Conllections中的bianarySeach ()方法时报错 no instance(s) of type vaiable(s) T text so that Student

python程序运行时报错,怎么处理?

15.python异常处理

python pip安装库时报错?

如何修改WAMP中mysql默认空密码 以及修改时报错的处理方法

win10下pip3安装tesserocr时报错