I’m using a 3rd party library called openpyxl to provide an excel spreadsheet interface. All of my custom libraries are stored in a ./Python/ folder local to the layout file for portability reasons.
Here’s my import code
from vcScript import *
import sys
if not sys.path[0] == 'Python':
sys.path.insert(0,'Python')
# Import Local modules here
import openpyxl
If I open a new instance of visual components, and load my layout, the library imports and works exactly as expected. However, sometimes if I recompile a script that imports the openpyxl library, I get an error:
Traceback (most recent call last):
File "MasterController::PythonScript", line 7, in <module>
File "Python\openpyxl\__init__.py", line 29, in <module>
from openpyxl.workbook import Workbook
File "Python\openpyxl\workbook\__init__.py", line 5, in <module>
from .workbook import Workbook
File "Python\openpyxl\workbook\workbook.py", line 8, in <module>
from openpyxl.worksheet import Worksheet
File "Python\openpyxl\worksheet\__init__.py", line 4, in <module>
from .worksheet import Worksheet
File "Python\openpyxl\worksheet\worksheet.py", line 34, in <module>
from openpyxl.cell import Cell
File "Python\openpyxl\cell\__init__.py", line 4, in <module>
from .cell import Cell, WriteOnlyCell
File "Python\openpyxl\cell\cell.py", line 45, in <module>
from openpyxl.styles import numbers, is_date_format
File "Python\openpyxl\styles\__init__.py", line 5, in <module>
from .alignment import Alignment
File "Python\openpyxl\styles\alignment.py", line 6, in <module>
from openpyxl.descriptors import Bool, MinMax, Min, Alias, NoneSet
File "Python\openpyxl\descriptors\__init__.py", line 5, in <module>
from .sequence import Sequence
File "Python\openpyxl\descriptors\sequence.py", line 5, in <module>
from openpyxl.xml.functions import Element
File "Python\openpyxl\xml\functions.py", line 78, in <module>
register_namespace(DCTERMS_PREFIX, DCTERMS_NS)
File "C:\Program Files\Visual Components\Visual Components Professional 4.0\Python\Lib\xml\etree\ElementTree.py", line 1025, in register_namespace
if re.match("ns\d+$", prefix):
AttributeError: 'NoneType' object has no attribute 'match'
What’s even weirder is that if I add whitespace to the ElementTree.py file and then recompile my script, it will throw errors for other parts of ElementTree.py. I haven’t found a way to make this error stop without restarting VC.