matplotlib.pyplot import报错: ValueError: _getfullpathname: embedded null character in path

本文针对在Windows10环境下使用Anaconda3.6时遇到的matplotlib导入错误问题进行了解决方案的探讨。错误提示为ValueError: _getfullpathname: embedded null character in path。通过修改Anaconda3/lib/site-packages/matplotlib/font_manager.py文件中win32InstalledFonts函数的部分代码解决了该问题。

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

Environment:

Windows 10,

Anaconda 3.6

matplotlib 2.0

 

import matplotlib.pyplot

报错:

ValueError: _getfullpathname: embedded null character in path

 

原因以及Solution:

http://stackoverflow.com/questions/34004063/error-on-import-matplotlib-pyplot-on-anaconda3-for-windows-10-home-64-bit-pc

 

修改的文件:

Anaconda3/lib/site-packages/matplotlib/font_manager.py

修改的函数:

 def win32InstalledFonts(directory=None, fontext='ttf'):

        try:
            for j in range(winreg.QueryInfoKey(local)[1]):
                try:
                    key, direc, any = winreg.EnumValue( local, j)
                    if not is_string_like(direc):
                        continue
                    if not os.path.dirname(direc):
                        direc = os.path.join(directory, direc)
                    # direc = os.path.abspath(direc).lower()
                    direc = direc.split('\0', 1)[0]
                    if os.path.splitext(direc)[1][1:] in fontext:
                        items[direc] = 1

 

转载于:https://www.cnblogs.com/norsd/p/6365904.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值