小编Xu *_*zhe的帖子

遇到opencv导入问题

我在使用opencv时遇到麻烦。

环境:python3.6.1,linux(HPC服务器),opevcv3.4.3.18

错误描述:我尝试Requirement already satisfied: opencv-python in /home/users/czxu/.local/lib/python3.6/site-packages (3.4.3.18)使用命令:成功安装()后导入cv2 import cv2,但似乎缺少文件夹或脚本:

Traceback (most recent call last):
  File "scripts/preprocessing/gen_mini_batches.py", line 4, in <module>
    from avod.builders.dataset_builder import DatasetBuilder
  File "/home/users/czxu/avod/avod/builders/dataset_builder.py", line 6, in <module>
    from avod.datasets.kitti.kitti_dataset import KittiDataset
  File "/home/users/czxu/avod/avod/datasets/kitti/kitti_dataset.py", line 11, in <module>
    from wavedata.wavedata.tools.core import calib_utils
  File "/home/users/czxu/avod/wavedata/wavedata/tools/core/calib_utils.py", line 3, in <module>
    import cv2
  File "/home/users/czxu/.local/lib/python3.6/site-packages/cv2/__init__.py", line 3, in <module>
    from .cv2 import *
ImportError: libXrender.so.1: cannot open shared object file: No such file or directory
srun: …
Run Code Online (Sandbox Code Playgroud)

python opencv

6
推荐指数
1
解决办法
2733
查看次数

调用全局变量时未解析的引用?

我打算在函数“In_queue”中调用两个全局变量(“head”和“tail”),结果成功调用了“head”但没有调用“tail”。错误是:

UnboundLocalError: local variable 'tail' referenced before assignment.
Run Code Online (Sandbox Code Playgroud)

而在另一个函数“Out_queue”中,两个变量都成功调用。

编码:

tail = NODE(VALUE())
head = NODE(VALUE())
def In_queue():
    try:
        node = Create_node(*(Get_value()))
    except:
        print("OVERFLOW: No room availible!\n")
        exit(0)
    if not head.nextprt or not tail.nextprt:
        tail.nextprt = head.nextprt = node
    else:
        tail.nextprt = node
        tail = node
    return None
def Out_queue():
    if head.nextprt == tail.nextprt:
        if not head.nextprt:
            print("UNDERFLOW: the queue is empty!\n")
            exit(0)
        else:
            node = head.nextprt
            head.nextprt = tail.nextprt = None
            return node.value
    else:
        node = head.nextprt
        head.nextprt = …
Run Code Online (Sandbox Code Playgroud)

python python-3.x

5
推荐指数
1
解决办法
9300
查看次数

标签 统计

python ×2

opencv ×1

python-3.x ×1