报错信息
python: can't open file '/17106/efficientdet_test.py': [Errno 2] No such file or directory
(yeap) root@di6v7d57tjc5h-0:/17106# cd /17106/PCP/Yet-Another-EfficientDet-Pytorch-master
(yeap) root@di6v7d57tjc5h-0:/17106/PCP/Yet-Another-EfficientDet-Pytorch-master# python efficientdet_test.py
Traceback (most recent call last):
File "/17106/PCP/Yet-Another-EfficientDet-Pytorch-master/efficientdet_test.py", line 12, in <module>
import cv2
File "/root/anaconda3/envs/yeap/lib/python3.9/site-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/root/anaconda3/envs/yeap/lib/python3.9/site-packages/cv2/__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/root/anaconda3/envs/yeap/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
以上是我在运行代码的(推理)测试测试代码时遇到的报错,后面上Google查了一下,发现安装pytorch后还得安装一下opencv-python-headless。
如果你是物理机,可以考虑直接在物理机真实环境下运行下述命令来安装,pip3未测试过,读者可自行尝试。
pip install opencv-python-headless
如果你是在服务器或物理机的Anaconda虚拟环境中运行代码,那么请先使用下面命令激活你的虚拟环境:
conda activate 虚拟环境名
接着再运行同物理机相同的安装命令即可,当然同学也可以使用conda命令来安装,如下:
conda install opencv-python-headless
但是我自己时不用这种解决方案的,因为你用过几次后会发现,很多包安装不上,因为它本身channel的原因,遇到的报错常常是下面这样的:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- opencv-python-headless
Current channels:
- https://repo.anaconda.com/pkgs/main/linux-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/linux-64
- https://repo.anaconda.com/pkgs/r/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
好吧,好像本文已经偏离中心了,我们到此为止,祝你科研愉快,累的时候别忘记找点乐子。