Bug report #18233

Getting 'ValueError: _getfullpathname: embedded null character in path' when trying to load plugins

Added by Geoffrey Baum over 2 years ago. Updated over 2 years ago.

Status:Closed
Priority:Normal
Assignee:Borys Jurgiel
Category:Windows Package
Affected QGIS version:3.0.0 Regression?:No
Operating System:Windows 10 64-bit Easy fix?:No
Pull Request or Patch supplied:No Resolution:up/downstream
Crashes QGIS or corrupts data:No Copied to github as #:26124

Description

Couldn't load plugin 'SemiAutomaticClassificationPlugin' due to an error when calling its classFactory() method

ValueError: _getfullpathname: embedded null character in path
Traceback (most recent call last):
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\font_manager.py", line 1432, in
_rebuild()
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\font_manager.py", line 1418, in _rebuild
fontManager = FontManager()
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\font_manager.py", line 1053, in init
self.ttffiles = findSystemFonts(paths) + findSystemFonts()
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\font_manager.py", line 325, in findSystemFonts
for f in win32InstalledFonts(fontdir):
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\font_manager.py", line 241, in win32InstalledFonts
direc = os.path.abspath(direc).lower()
File "C:\OSGEO4~1\apps\Python36\lib\ntpath.py", line 544, in abspath
path = _getfullpathname(path)
ValueError: _getfullpathname: embedded null character in path

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 336, in startPlugin
plugins[packageName] = package.classFactory(iface)
File "C:/Users/Geof Baum/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\__init__.py", line 65, in classFactory
from .semiautomaticclassificationplugin import SemiAutomaticClassificationPlugin
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 664, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/Geof Baum/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\semiautomaticclassificationplugin.py", line 74, in
from .ui.semiautomaticclassificationplugindialog import SemiAutomaticClassificationPluginDialog
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 664, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/Geof Baum/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\ui\semiautomaticclassificationplugindialog.py", line 39, in
from .ui_semiautomaticclassificationplugin_scatter_plot import Ui_ScatterPlot
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 664, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/Geof Baum/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\ui\ui_semiautomaticclassificationplugin_scatter_plot.py", line 453, in
from .scatterwidget2 import ScatterWidget2
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 664, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/Geof Baum/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\ui\scatterwidget2.py", line 44, in
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigCanvas
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 664, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 13, in
from matplotlib.figure import Figure
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 664, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\figure.py", line 38, in
import matplotlib.colorbar as cbar
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 664, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\colorbar.py", line 36, in
import matplotlib.contour as contour
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 664, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\contour.py", line 22, in
import matplotlib.font_manager as font_manager
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 664, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\font_manager.py", line 1439, in
_rebuild()
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\font_manager.py", line 1418, in _rebuild
fontManager = FontManager()
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\font_manager.py", line 1053, in init
self.ttffiles = findSystemFonts(paths) + findSystemFonts()
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\font_manager.py", line 325, in findSystemFonts
for f in win32InstalledFonts(fontdir):
File "C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib\font_manager.py", line 241, in win32InstalledFonts
direc = os.path.abspath(direc).lower()
File "C:\OSGEO4~1\apps\Python36\lib\ntpath.py", line 544, in abspath
path = _getfullpathname(path)
ValueError: _getfullpathname: embedded null character in path

Python version: 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)]
QGIS version: 3.0.0-Girona Girona, 001c80b0c3

Python Path:
C:/OSGEO4~1/apps/qgis/./python
C:/Users/Geof Baum/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/Geof Baum/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/OSGEO4~1/apps/qgis/./python/plugins
C:\OSGeo4W64\bin\python36.zip
C:\OSGEO4~1\apps\Python36\DLLs
C:\OSGEO4~1\apps\Python36\lib
C:\OSGeo4W64\bin
C:\OSGEO4~1\apps\Python36
C:\OSGEO4~1\apps\Python36\lib\site-packages
C:/Users/Geof Baum/AppData/Roaming/QGIS/QGIS3\profiles\default/python

History

#1 Updated by Borys Jurgiel over 2 years ago

You only get the error when loading matplotlib-based plugins, don't you?
For example, autoSaver (or any other plugin not using matplotlib) works properly, doesn't it?

Looks like a bug in OSGeo4W's matplotlib.

#2 Updated by Geoffrey Baum over 2 years ago

Borys Jurgiel wrote:

You only get the error when loading matplotlib-based plugins, don't you?
For example, autoSaver (or any other plugin not using matplotlib) works properly, doesn't it?

Looks like a bug in OSGeo4W's matplotlib.

Yes it appears that it is connected solely with matplotlib. I checked some more like with autoSaver and do not have an issue, my luck the first 5 or so plugins I checked that I use normally all use matplotlib.

#3 Updated by Borys Jurgiel over 2 years ago

  • Category changed from Plugin Manager to Windows Package

Well it looks like some conflicts in your C:\OSGeo4W. I can't reproduce your problem with the standalone installer - and it's basically a fresh install of packages taken from OSGeo4W. Unfortunately can't test fresh OSGeo4W now, as the server seems overloaded.

Today some people had problems with obsolete *pyc files in C:\OSGeo4W\apps\qgis . Maybe you have similar problem in C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib ?

I'd try to remove all the *pyc files from OsGeo4W. Hopefully all necessary *py files are there, so you won't need to reinstall all packages ;)

You can also test the standalone version.

#4 Updated by Geoffrey Baum over 2 years ago

Borys Jurgiel wrote:

Well it looks like some conflicts in your C:\OSGeo4W. I can't reproduce your problem with the standalone installer - and it's basically a fresh install of packages taken from OSGeo4W. Unfortunately can't test fresh OSGeo4W now, as the server seems overloaded.

Today some people had problems with obsolete *pyc files in C:\OSGeo4W\apps\qgis . Maybe you have similar problem in C:\OSGEO4~1\apps\Python36\lib\site-packages\matplotlib ?

I'd try to remove all the *pyc files from OsGeo4W. Hopefully all necessary *py files are there, so you won't need to reinstall all packages ;)

You can also test the standalone version.

I just did a quick check with just the matplotlib folder. Fortunately, removing all of the *pyc files was easy since they are just in the pycache folder. Unfortunately, upon reboot that folder is recreated and I still have my error. Currently downloading the standalone version and hope to install on a seperate drive just to see if I can recreate the problem and will update with any conclusions. I'll also try to remove all of the *pyc files in the OsGeo4W folder and recheck that approach to see if it's a continuing issue on that front.

#5 Updated by Geoffrey Baum over 2 years ago

So far the standalone version on another drive gives me the same errors. The errors even point to the specific drive partition and folder so I know they aren't for some reason at least just finding the errors from the other OsGeoW4 install as far as I can tell. A complete reinstall will have to happen tonight once I have time.

#6 Updated by Geoffrey Baum over 2 years ago

So I feel like I've done a complete reinstall, and complete uninstall with then reinstall just by quick install but I'm still getting the same issue. I gave up on the advanced install just to try and figure out the issue but it doesn't seem like it's going anywhere.

#7 Updated by Geoffrey Baum over 2 years ago

Did an install on a seperate computer (Windows 7 64bit) that already had an older version of QGIS, and the install and the ability to utilize the plugins that were causing this error did not appear. Still reporting an error for my Windows 10 64-bit machine.

#8 Updated by Giovanni Manghi over 2 years ago

  • Status changed from Open to Feedback

#10 Updated by Geoffrey Baum over 2 years ago

Borys Jurgiel wrote:

Then maybe some obsolete registry entries... You can also try the fixes from Stackoverflow:

https://stackoverflow.com/questions/40141423/python-error-valueerror-getfullpathname-embedded-null-character
https://stackoverflow.com/questions/34004063/error-on-import-matplotlib-pyplot-on-anaconda3-for-windows-10-home-64-bit-pc

Frankly speaking, can't help more...

Thank you for your help, I had looked at those two fixes previously but it seemed like an odd thing to fix considering that matplotlib running through my Conda instance has never given me this type of error before at all. Either way, the fix that works for me is to change line 241 of the the file font_manager.py in the matplotlib folder from:

direc = os.path.abspath(direc).lower()

to

direc = direc.split('\0', 1)[0]

It's the accepted answer from your second link and I tried the secondary answer on that link as well to change the issue in the actual ntpath.py file that seems to be the actual culprit but QGIS did not get past the loading python portion of it's start up.

I still don't understand why it created this error when it doesn't in my Python environment but I guess I'll have to dig a little deeper on my own time. This should provide a fix for anyone else who might get this same error so this can probably be a closed issue now.

#11 Updated by Nyall Dawson over 2 years ago

  • Resolution set to up/downstream
  • Status changed from Feedback to Closed

Also available in: Atom PDF