python3不用import logging,因为logging已经内置了。
参考:https://stackoverflow.com/questions/32386469/logging-module-not-working-with-python3
报错:RecursionError: maximum recursion depth exceeded while calling a Python object
# python3 运行 import logging报错
Traceback (most recent call last):File "/home/xxx/folder1/utee/misc.py", line 32, in infoself.init('/tmp', 'tmp.log')File "/home/xxx/folder1/utee/misc.py", line 22, in initprint(log_file)File "/home/xxx/folder1/utee/misc.py", line 32, in infoself.init('/tmp', 'tmp.log')...File "/home/xxx/folder1/utee/misc.py", line 32, in infoself.init('/tmp', 'tmp.log')File "/home/xxx/folder1/utee/misc.py", line 17, in initimport logging
RecursionError: maximum recursion depth exceeded while calling a Python object
python3 pip3 安装 logging报错:url: /simple/logging/ (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),))
$ sudo -H pip3 --proxy=xx.xxx.xx.xxx:8080 install logging
# 报错内容:SSL报错。
Collecting loggingWARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),)': /simple/logging/WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),)': /simple/logging/WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),)': /simple/logging/WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),)': /simple/logging/WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),)': /simple/logging/Could not fetch URL https://pypi.org/simple/logging/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/logging/ (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),)) - skippingERROR: Could not find a version that satisfies the requirement logging (from versions: none)
ERROR: No matching distribution found for logging
# 解决:设置可信的域名。 (--trusted-host pypi.org --trusted-host files.pythonhosted.org)
$ sudo -H pip3 --proxy=xx.xxx.xx.xxx:8080 --trusted-host pypi.org --trusted-host files.pythonhosted.org install logging
还是报错: raise NotImplementedError, 'emit must be implemented '\
# 报错内容
Collecting loggingDownloading https://files.pythonhosted.org/packages/93/4b/979db9e44be09f71e85c9c8cfc42f258adfb7d93ce01deed2788b2948919/logging-0.4.9.6.tar.gz (96kB)|????????????????????????????????????????????????????????????????| 102kB 529kB/sERROR: Command errored out with exit status 1:command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-u8g87k38/logging/setup.py'"'"'; __file__='"'"'/tmp/pip-install-u8g87k38/logging/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-infocwd: /tmp/pip-install-u8g87k38/logging/Complete output (44 lines):running egg_infocreating pip-egg-info/logging.egg-infowriting pip-egg-info/logging.egg-info/PKG-INFOwriting dependency_links to pip-egg-info/logging.egg-info/dependency_links.txtwriting top-level names to pip-egg-info/logging.egg-info/top_level.txtwriting manifest file 'pip-egg-info/logging.egg-info/SOURCES.txt'Traceback (most recent call last):File "<string>", line 1, in <module>File "/tmp/pip-install-u8g87k38/logging/setup.py", line 13, in <module>packages = ["logging"],File "/usr/lib/python3.5/distutils/core.py", line 148, in setupdist.run_commands()File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commandsself.run_command(cmd)File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_commandcmd_obj.run()File "/usr/local/lib/python3.5/dist-packages/setuptools-19.6-py3.5.egg/setuptools/command/egg_info.py", line 186, in runFile "/usr/local/lib/python3.5/dist-packages/setuptools-19.6-py3.5.egg/setuptools/command/egg_info.py", line 209, in find_sourcesFile "/usr/local/lib/python3.5/dist-packages/setuptools-19.6-py3.5.egg/setuptools/command/egg_info.py", line 293, in runFile "/usr/local/lib/python3.5/dist-packages/setuptools-19.6-py3.5.egg/setuptools/command/egg_info.py", line 322, in add_defaultsFile "/usr/local/lib/python3.5/dist-packages/setuptools-19.6-py3.5.egg/setuptools/command/sdist.py", line 120, in add_defaultsFile "/usr/lib/python3.5/distutils/cmd.py", line 298, in get_finalized_commandcmd_obj = self.distribution.get_command_obj(command, create)File "/usr/lib/python3.5/distutils/dist.py", line 846, in get_command_objklass = self.get_command_class(command)File "/usr/local/lib/python3.5/dist-packages/setuptools-19.6-py3.5.egg/setuptools/dist.py", line 430, in get_command_classFile "/usr/local/lib/python3.5/dist-packages/setuptools-19.6-py3.5.egg/pkg_resources/__init__.py", line 2370, in loadFile "/usr/local/lib/python3.5/dist-packages/setuptools-19.6-py3.5.egg/pkg_resources/__init__.py", line 2376, in resolveFile "<frozen importlib._bootstrap>", line 969, in _find_and_loadFile "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 664, in _load_unlockedFile "<frozen importlib._bootstrap>", line 634, in _load_backward_compatibleFile "/usr/local/lib/python3.5/dist-packages/setuptools-19.6-py3.5.egg/setuptools/command/build_py.py", line 15, in <module>File "<frozen importlib._bootstrap>", line 969, in _find_and_loadFile "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 664, in _load_unlockedFile "<frozen importlib._bootstrap>", line 634, in _load_backward_compatibleFile "/usr/local/lib/python3.5/dist-packages/setuptools-19.6-py3.5.egg/setuptools/lib2to3_ex.py", line 12, in <module>File "/usr/lib/python3.5/lib2to3/refactor.py", line 19, in <module>import loggingFile "/tmp/pip-install-u8g87k38/logging/logging/__init__.py", line 618raise NotImplementedError, 'emit must be implemented '\^SyntaxError: invalid syntax----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.