1. 安装
labelimg版本较低需要在python3.8的环境中进行安装,先准备好环境,这部分不再这里说明,使用pip安装
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ labelimg
执行后报一下错误:
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [95 lines of output]
ERROR: Exception:
Traceback (most recent call last):
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 438, in _error_catcher
yield
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 561, in read
data = self._fp_read(amt) if not fp_closed else b""
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 527, in _fp_read
return self._fp.read(amt) if amt is not None else self._fp.read()
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 98, in read
data: bytes = self.__fp.read(amt)
File "/opt/anaconda3/envs/python38/lib/python3.8/http/client.py", line 459, in read
n = self.readinto(b)
File "/opt/anaconda3/envs/python38/lib/python3.8/http/client.py", line 503, in readinto
n = self.fp.readinto(b)
File "/opt/anaconda3/envs/python38/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "/opt/anaconda3/envs/python38/lib/python3.8/ssl.py", line 1274, in recv_into
return self.read(nbytes, buffer)
File "/opt/anaconda3/envs/python38/lib/python3.8/ssl.py", line 1132, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
status = run_func(*args)
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 245, in wrapper
return func(self, options, args)
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_internal/commands/wheel.py", line 147, in run
requirement_set = resolver.resolve(reqs, check_supported_wheels=True)
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 179, in resolve
self.factory.preparer.prepare_linked_requirements_more(reqs)
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 552, in prepare_linked_requirements_more
self._complete_partial_requirements(
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 467, in _complete_partial_requirements
for link, (filepath, _) in batch_download:
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_internal/network/download.py", line 183, in __call__
for chunk in chunks:
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_internal/network/utils.py", line 63, in response_chunks
for chunk in response.raw.stream(
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 622, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 587, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/opt/anaconda3/envs/python38/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 443, in _error_catcher
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
/opt/anaconda3/envs/python38/lib/python3.8/site-packages/setuptools/__init__.py:81: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!
********************************************************************************
Requirements should be satisfied by a PEP 517 installer.
If you are using pip, you can try `pip install --use-pep517`.
********************************************************************************
!!
dist.fetch_build_eggs(dist.setup_requires)
Traceback (most recent call last):
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/setuptools/installer.py", line 101, in _fetch_build_egg_no_warn
subprocess.check_call(cmd)
File "/opt/anaconda3/envs/python38/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/opt/anaconda3/envs/python38/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/var/folders/b7/wlk0lrw11g34__zgp9k59xq00000gn/T/tmp8eb_a_g5', '--quiet', 'py2app']' returned non-zero exit status 2.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/private/var/folders/b7/wlk0lrw11g34__zgp9k59xq00000gn/T/pip-install-3ld0a0vg/labelimg_8173eb60295540e599f9d6a980548bdd/setup.py", line 84, in <module>
setup(
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/setuptools/__init__.py", line 103, in setup
_install_setup_requires(attrs)
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/setuptools/__init__.py", line 76, in _install_setup_requires
_fetch_build_eggs(dist)
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/setuptools/__init__.py", line 81, in _fetch_build_eggs
dist.fetch_build_eggs(dist.setup_requires)
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/setuptools/dist.py", line 640, in fetch_build_eggs
return _fetch_build_eggs(self, requires)
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/setuptools/installer.py", line 38, in _fetch_build_eggs
resolved_dists = pkg_resources.working_set.resolve(
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pkg_resources/__init__.py", line 798, in resolve
dist = self._resolve_dist(
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pkg_resources/__init__.py", line 834, in _resolve_dist
dist = best[req.key] = env.best_match(
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1104, in best_match
return self.obtain(req, installer)
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1115, in obtain
return installer(requirement) if installer else None
File "/opt/anaconda3/envs/python38/lib/python3.8/site-packages/setuptools/installer.py", line 103, in _fetch_build_egg_no_warn
raise DistutilsError(str(e)) from e
distutils.errors.DistutilsError: Command '['/opt/anaconda3/envs/python38/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/var/folders/b7/wlk0lrw11g34__zgp9k59xq00000gn/T/tmp8eb_a_g5', '--quiet', 'py2app']' returned non-zero exit status 2.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
2. 解决方法
此问题产生的原因是版本不匹配导致的,主要是pip和setuptools,进行升级
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ --upgrade pip setuptools
升级生成后再进行安装,此时会安装成功,