win10在anaconda虚拟环境中配置pysot:ModuleNotFoundError: No module named ‘pysot‘

这篇博客介绍了在Windows下遇到Python导入pysot模块错误的解决方法。通过创建并运行exporttest.py脚本,更新sys.path,将pysot库的路径添加到环境变量中,从而解决ModuleNotFoundError。步骤包括编写python文件添加路径到.pth文件,并检查避免重复添加。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1,下载源码,在anaconda虚拟环境中配置pysot环境
2,运行demo.py

python tools/demo.py  --config experiments/siamrpn_r50_l234_dwxcorr/config.yaml  --snapshot experiments/siamrpn_r50_l234_dwxcorr/model.pth --video demo/1.avi

报错:ModuleNotFoundError: No module named ‘pysot’

在linux环境下该报错比较好解决
windows在的解决方式如下:

1、新建一个python文件exporttest.py,放置于工程源码路径

内容如下:

import argparse
import sys
from pathlib import Path
 
parser = argparse.ArgumentParser()
parser.add_argument("--path", type=str, default="")
parser.add_argument("--deletepath", type=str, default="")
args = parser.parse_args()
 
# sys.path.append(r'newlib_path')
 
if __name__ == '__main__':
 
    exportpath = eval(repr(args.path).replace('\\', '\\\\'))
    exportpathlist=exportpath.split('AND')
    # print(pathlist)
    # print(sys.executable)
 
    deletepath = eval(repr(args.deletepath).replace('\\', '\\\\'))
    deletepathlist = deletepath.split('AND')
 
    filepath=sys.prefix+'\Lib\site-packages\myExportPath.pth'
    file = Path(filepath)
 
    if not file.exists():
        # print("File doesn't exist, this code will first create one and then add the paths!!!")
        with file.open('w') as f:
            for path in exportpathlist:
                f.write(path)
                f.write("\n")
        existingPaths = file.read_text()
        existingPathslist = filter(None, existingPaths.split('\n'))
        with file.open('w') as f:  # 创建并写入。
            for existingPath in existingPathslist:
                deleteFlag=False
                for path in deletepathlist:
                    if existingPath == path:
                        deleteFlag=True
                        break
                if deleteFlag==False:
                    f.write(existingPath)
                    f.write("\n")
        existingPaths = file.read_text()
        print("The export paths are: \n"+existingPaths)
    else:
        # print("The file exists, this code will add the paths to the existing file!!!")
        existingPaths=file.read_text()
        existingPathslist = filter(None,existingPaths.split('\n'))
        with file.open('a') as f:
            for path in exportpathlist:
                existingFlag=False
                for existingPath in existingPathslist:
                    if existingPath == path:
                        existingFlag=True
                        print("warning: the path "+path+" already exists")
                        break
                if existingFlag==False:
                    f.write(path)
                    f.write("\n")
        existingPaths = file.read_text()
        existingPathslist = filter(None, existingPaths.split('\n'))
        with file.open('w') as f:
            for existingPath in existingPathslist:
                deleteFlag = False
                for path in deletepathlist:
                    if existingPath == path:
                        deleteFlag = True
                        break
                if deleteFlag == False:
                    f.write(existingPath)
                    f.write("\n")
        existingPaths = file.read_text()
        print("The export paths are: \n" + existingPaths)
    # print(sys.path)

2 cd到exporttest.py所在目录,执行

python exporttest.py --deletepath E:\dplearning\pysot-master\

执行之后会在源码目录

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

视觉AI

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值