os.path.sep.join([site.USER_SITE, 'paddle', 'libs']) TypeError: sequence item 0: expected str instance, NoneType found 报错解决方法。

nbysray5  于 5个月前  发布在  其他
关注(0)|答案(1)|浏览(54)

问题描述 Please describe your issue

File "E:\pctest\PyStand_ocr\site-packages\paddle\base_init_.py", line 36, in
from . import core
File "E:\pctest\PyStand_ocr\site-packages\paddle\base\core.py", line 418, in
set_paddle_lib_path()
File "E:\pctest\PyStand_ocr\site-packages\paddle\base\core.py", line 410, in set_paddle_lib_path
lib_dir = os.path.sep.join([site.USER_SITE, 'paddle', 'libs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: sequence item 0: expected str instance, NoneType found
我在尝试打包paddleocr的时候遇到 这个site.USER_SITE,报错 ,找了不少方案都没解决,打包后的路径还是错误,可以site-packages\paddle\base\core.py对set_paddle_lib_path函数进行修改就可以解决问题,我遇到这个搜了不少方案,找到一份解决方案,所以我单独写出来方便大家,由于我是第一次在github发帖,不会粘贴代码,我发现下面的代码被分成2部分了。

def set_paddle_lib_path():
    site_dirs = (
        site.getsitepackages()
        if hasattr(site, 'getsitepackages')
        else [x for x in sys.path if 'site-packages' in x]
    )
    for site_dir in site_dirs:
        lib_dir = os.path.sep.join([site_dir, 'paddle', 'libs'])
        if os.path.exists(lib_dir):
            _set_paddle_lib_path(lib_dir)
            set_paddle_custom_device_lib_path(
                os.path.sep.join([lib_dir, '..', '..', 'paddle-plugins'])
            )
            return

    if getattr(sys, 'frozen', False):
        basedir = sys._MEIPASS
    else:
        basedir = os.path.dirname(os.path.abspath(__file__))

    lib_dir = os.path.join(basedir, 'site-packages', 'paddle', 'libs')
    if os.path.exists(lib_dir):
        _set_paddle_lib_path(lib_dir)
        set_paddle_custom_device_lib_path(
            os.path.sep.join([lib_dir, '..', '..', 'paddle-plugins'])
        )
zf2sa74q

zf2sa74q1#

Hi q313766934! Thank you very much for your attention and contribution to the PaddlePaddle community!

Your issue has improved the user installation experience of Paddleocr and played a positive role in the prosperity of the PaddlePaddle framework and community. Welcome to continue following and provide any modification suggestions!

相关问题