一、常规在线安装方法
1.1、查看python版本和pip已安装包
C:\Users\Administrator>python
Python 3.11.6 (tags/v3.11.6:8b6ee5b, Oct 2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
C:\Users\Administrator>pip list
Package Version
---------- -------
pip 23.2.1
setuptools 65.5.0
[notice] A new release of pip is available: 23.2.1 -> 24.0
[notice] To update, run: python.exe -m pip install --upgrade pip
1.2、尝试从清华源(pip install cnocr -i https://pypi.tuna.tsinghua.edu.cn/simple)安装,出现异常“TimeoutError”:这个问题可能是由于网络连接不稳定或者下载速度过慢导致的。
C:\Users\Administrator>pip install cnocr -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting cnocr
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b5/3d/c978986e04468dbbb3fb490cce28a33af7b7c6b287fa6308c489d3a65b0e/cnocr-2.3.0.2-py3-none-any.whl (222 kB)
---------------------------------------- 222.1/222.1 kB 847.4 kB/s eta 0:00:00
Collecting click (from cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl (97 kB)
---------------------------------------- 97.9/97.9 kB 626.4 kB/s eta 0:00:00
Collecting tqdm (from cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/18/eb/fdb7eb9e48b7b02554e1664afd3bd3f117f6b6d6c5881438a0b055554f9b/tqdm-4.66.4-py3-none-any.whl (78 kB)
---------------------------------------- 78.3/78.3 kB 624.2 kB/s eta 0:00:00
Collecting torch>=1.8.0 (from cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2a/b7/a3cf5fd40334b9785cc83ee0c96b50603026eb3aa70210a33729018e7029/torch-2.3.0-cp311-cp311-win_amd64.whl (159.8 MB)
---------------------------------------- 159.8/159.8 MB 2.9 MB/s eta 0:00:00
Collecting torchvision>=0.9.0 (from cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/12/c2/7c89c62f2b0a606070aa7cdb8af8af0c905562942778ebdd77600642c3b9/torchvision-0.18.0-cp311-cp311-win_amd64.whl (1.2 MB)
---------------------------------------- 1.2/1.2 MB 2.3 MB/s eta 0:00:00
Collecting numpy (from cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3f/6b/5610004206cf7f8e7ad91c5a85a8c71b2f2f8051a0c0c4d5916b76d6cbb2/numpy-1.26.4-cp311-cp311-win_amd64.whl (15.8 MB)
---------------------------------------- 15.8/15.8 MB 2.5 MB/s eta 0:00:00
Collecting pytorch-lightning>=2.0.0 (from cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/15/e7/1fd6d37b1f447ca9ccece954e9f09e89b551af6fcab3ae5345b83dce8c1b/pytorch_lightning-2.2.4-py3-none-any.whl (802 kB)
---------------------------------------- 802.2/802.2 kB 1.7 MB/s eta 0:00:00
Collecting wandb (from cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c1/00/ce87cdf89c8b4d6414d65b3359b14684fc36477d838d3fdea38c1ae24638/wandb-0.17.0-py3-none-win_amd64.whl (6.7 MB)
---------------------------------------- 6.7/6.7 MB 1.9 MB/s eta 0:00:00
Collecting torchmetrics (from cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/aa/d9/b235d32de0f496492b108db7aea0cda42c58b713e2547a149385f1dfc8e3/torchmetrics-1.4.0-py3-none-any.whl (868 kB)
---------------------------------------- 868.8/868.8 kB 1.8 MB/s eta 0:00:00
Collecting pillow>=5.3.0 (from cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/0a/16/c83877524c47976f16703d2e05c363244bc1e60ab439e078b3cd046d07db/pillow-10.3.0-cp311-cp311-win_amd64.whl (2.5 MB)
---------------------------------------- 2.5/2.5 MB 1.7 MB/s eta 0:00:00
Collecting onnx (from cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/aa/d0/0514d02d2e84e7bb48a105877eae4065e54d7dabb60d0b60214fe2677346/onnx-1.16.0-cp311-cp311-win_amd64.whl (14.4 MB)
---------------------------------------- 14.4/14.4 MB 2.8 MB/s eta 0:00:00
Collecting cnstd>=1.2.3.4 (from cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/99/d8/70886b60c977c4359ba59bd37e0428c7165702d4cb73fb75994d8a97db2d/cnstd-1.2.3.6-py3-none-any.whl (246 kB)
---------------------------------------- 246.5/246.5 kB 1.0 MB/s eta 0:00:00
Collecting pyyaml (from cnstd>=1.2.3.4->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b3/34/65bb4b2d7908044963ebf614fe0fdb080773fc7030d7e39c8d3eddcd4257/PyYAML-6.0.1-cp311-cp311-win_amd64.whl (144 kB)
---------------------------------------- 144.7/144.7 kB 1.7 MB/s eta 0:00:00
Collecting unidecode (from cnstd>=1.2.3.4->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/84/b7/6ec57841fb67c98f52fc8e4a2d96df60059637cba077edc569a302a8ffc7/Unidecode-1.3.8-py3-none-any.whl (235 kB)
---------------------------------------- 235.5/235.5 kB 2.9 MB/s eta 0:00:00
Collecting scipy (from cnstd>=1.2.3.4->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d4/a1/d4adf25b6d2bef8d0ad1682829dcfcba97f3f96bb5b6f137bc3e41003cc7/scipy-1.13.0-cp311-cp311-win_amd64.whl (46.2 MB)
---------------------------------------- 46.2/46.2 MB 308.6 kB/s eta 0:00:00
Collecting pandas (from cnstd>=1.2.3.4->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ab/63/966db1321a0ad55df1d1fe51505d2cdae191b84c907974873817b0a6e849/pandas-2.2.2-cp311-cp311-win_amd64.whl (11.6 MB)
---------------------------------------- 11.6/11.6 MB 373.8 kB/s eta 0:00:00
Collecting opencv-python>=4.0.0 (from cnstd>=1.2.3.4->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c7/ec/9dabb6a9abfdebb3c45b0cc52dec901caafef2b2c7e7d6a839ed86d81e91/opencv_python-4.9.0.80-cp37-abi3-win_amd64.whl (38.6 MB)
---------------------------------------- 38.6/38.6 MB 379.8 kB/s eta 0:00:00
Collecting shapely (from cnstd>=1.2.3.4->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6a/5c/3330f499ca860f0b92db4ceaebd7090096a83c1ea3ae7d8d4c6111761b82/shapely-2.0.4-cp311-cp311-win_amd64.whl (1.4 MB)
---------------------------------------- 1.4/1.4 MB 319.1 kB/s eta 0:00:00
Collecting Polygon3 (from cnstd>=1.2.3.4->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1f/26/eea4112be43c8b7345477ad9150d499303494f32fb5951cb0f6e9104045b/Polygon3-3.0.9.1.tar.gz (39 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting pyclipper (from cnstd>=1.2.3.4->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f3/ec/56da9f2d5d846f144530d5313a05078afb7cfc26ec179be5af35f057d064/pyclipper-1.3.0.post5-cp311-cp311-win_amd64.whl (108 kB)
---------------------------------------- 108.3/108.3 kB 36.1 kB/s eta 0:00:00
Collecting matplotlib (from cnstd>=1.2.3.4->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2d/d5/6227732ecab9165586966ccb54301e3164f61b470c954c4cf6940654fbe1/matplotlib-3.8.4-cp311-cp311-win_amd64.whl (7.7 MB)
---------------------------------------- 7.7/7.7 MB 126.2 kB/s eta 0:00:00
Collecting seaborn (from cnstd>=1.2.3.4->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/83/11/00d3c3dfc25ad54e731d91449895a79e4bf2384dc3ac01809010ba88f6d5/seaborn-0.13.2-py3-none-any.whl (294 kB)
---------------------------------------- 294.9/294.9 kB 109.8 kB/s eta 0:00:00
Collecting huggingface-hub (from cnstd>=1.2.3.4->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/21/2b/516f82c5ba9beb184b24c11976be2ad5e80fb7fe6b2796c887087144445e/huggingface_hub-0.23.0-py3-none-any.whl (401 kB)
---------------------------------------- 401.2/401.2 kB 106.0 kB/s eta 0:00:00
Collecting fsspec[http]>=2022.5.0 (from pytorch-lightning>=2.0.0->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/93/6d/66d48b03460768f523da62a57a7e14e5e95fdf339d79e996ce3cecda2cdb/fsspec-2024.3.1-py3-none-any.whl (171 kB)
---------------------------------------- 172.0/172.0 kB 117.6 kB/s eta 0:00:00
Collecting packaging>=20.0 (from pytorch-lightning>=2.0.0->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/49/df/1fceb2f8900f8639e278b056416d49134fb8d84c5942ffaa01ad34782422/packaging-24.0-py3-none-any.whl (53 kB)
---------------------------------------- 53.5/53.5 kB 277.2 kB/s eta 0:00:00
Collecting typing-extensions>=4.4.0 (from pytorch-lightning>=2.0.0->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/01/f3/936e209267d6ef7510322191003885de524fc48d1b43269810cd589ceaf5/typing_extensions-4.11.0-py3-none-any.whl (34 kB)
Collecting lightning-utilities>=0.8.0 (from pytorch-lightning>=2.0.0->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5e/9e/e7768a8e363fc6f0c978bb7a0aa7641f10d80be60000e788ef2f01d34a7c/lightning_utilities-0.11.2-py3-none-any.whl (26 kB)
Collecting filelock (from torch>=1.8.0->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/41/24/0b023b6537dfc9bae2c779353998e3e99ac7dfff4222fc6126650e93c3f3/filelock-3.14.0-py3-none-any.whl (12 kB)
Collecting sympy (from torch>=1.8.0->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d2/05/e6600db80270777c4a64238a98d442f0fd07cc8915be2a1c16da7f2b9e74/sympy-1.12-py3-none-any.whl (5.7 MB)
---------------------------------------- 5.7/5.7 MB 176.3 kB/s eta 0:00:00
Collecting networkx (from torch>=1.8.0->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/38/e9/5f72929373e1a0e8d142a130f3f97e6ff920070f87f91c4e13e40e0fba5a/networkx-3.3-py3-none-any.whl (1.7 MB)
---------------------------------------- 1.7/1.7 MB 203.9 kB/s eta 0:00:00
Collecting jinja2 (from torch>=1.8.0->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/31/80/3a54838c3fb461f6fec263ebf3a3a41771bd05190238de3486aae8540c36/jinja2-3.1.4-py3-none-any.whl (133 kB)
---------------------------------------- 133.3/133.3 kB 154.6 kB/s eta 0:00:00
Collecting mkl<=2021.4.0,>=2021.1.1 (from torch>=1.8.0->cnocr)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fe/1c/5f6dbf18e8b73e0a5472466f0ea8d48ce9efae39bd2ff38cebf8dce61259/mkl-2021.4.0-py2.py3-none-win_amd64.whl (228.5 MB)
--------------- ------------------------ 90.1/228.5 MB 926.0 kB/s eta 0:02:30
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcher
yield
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\urllib3\response.py", line 561, in read
data = self._fp_read(amt) if not fp_closed else b""
^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\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 "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 90, in read
data = self.__fp.read(amt)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 466, in read
s = self.fp.read(amt)
^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\socket.py", line 706, in readinto
return self._sock.recv_into(b)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1311, in recv_into
return self.read(nbytes, buffer)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1167, in read
return self._sslobj.read(len, buffer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_internal\cli\base_command.py", line 180, in exc_logging_wrapper
status = run_func(*args)
^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_internal\cli\req_command.py", line 248, in wrapper
return func(self, options, args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_internal\commands\install.py", line 377, in run
requirement_set = resolver.resolve(
^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 92, in resolve
result = self._result = resolver.resolve(
^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 546, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 427, in resolve
failure_causes = self._attempt_to_pin_criterion(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 239, in _attempt_to_pin_criterion
criteria = self._get_updated_criteria(candidate)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 230, in _get_updated_criteria
self._add_to_crite