ebroecker / canmatrix

Converting Can (Controller Area Network) Database Formats .arxml .dbc .dbf .kcd ...
BSD 2-Clause "Simplified" License
924 stars 399 forks source link

ValueError cannot use LOCALE flag with a str pattern #112

Closed Andrei1Byte closed 6 years ago

Andrei1Byte commented 6 years ago

Hello,

I receive this error "ValueError cannot use LOCALE flag with a str pattern", when I try to run anything related to this project. For example I tried to run test.py:

This is the output:

:\Users\uidj5318\Desktop\canmatrix-development\test>py test.py Traceback (most recent call last): File "test.py", line 10, in import canmatrix.convert File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 656, in _load_unlocked File "", line 626, in _load_backward_compatible File "C:\Program Files\lib\site-packages\canmatrix-0.6.1rc0-py3.6.egg\canmatrix\convert.py", line 32, in File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 656, in _load_unlocked File "", line 626, in _load_backward_compatible File "C:\Program Files\lib\site-packages\canmatrix-0.6.1rc0-py3.6.egg\canmatrix\formats.py", line 21, in File "C:\Program Files\lib\importlib__init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 656, in _load_unlocked File "", line 626, in _load_backward_compatible File "C:\Program Files\lib\site-packages\canmatrix-0.6.1rc0-py3.6.egg\canmatrix\xls.py", line 35, in File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 656, in _load_unlocked File "", line 626, in _load_backward_compatible File "C:\Program Files\lib\site-packages\xlwt_future-0.8.0-py3.6.egg\xlwt\init__.py", line 5, in File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 656, in _load_unlocked File "", line 626, in _load_backward_compatible File "C:\Program Files\lib\site-packages\xlwt_future-0.8.0-py3.6.egg\xlwt\Row.py", line 9, in File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 656, in _load_unlocked File "", line 626, in _load_backward_compatible File "C:\Program Files\lib\site-packages\xlwt_future-0.8.0-py3.6.egg\xlwt\ExcelFormula.py", line 8, in File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 656, in _load_unlocked File "", line 626, in _load_backward_compatible File "C:\Program Files\lib\site-packages\xlwt_future-0.8.0-py3.6.egg\xlwt\ExcelFormulaLexer.py", line 55, in File "C:\Program Files\lib\re.py", line 233, in compile return _compile(pattern, flags) File "C:\Program Files\lib\re.py", line 301, in _compile p = sre_compile.compile(pattern, flags) File "C:\Program Files\lib\sre_compile.py", line 562, in compile p = sre_parse.parse(p, flags) File "C:\Program Files\lib\sre_parse.py", line 865, in parse p.pattern.flags = fix_flags(str, p.pattern.flags) File "C:\Program Files\lib\sre_parse.py", line 832, in fix_flags raise ValueError("cannot use LOCALE flag with a str pattern") ValueError: cannot use LOCALE flag with a str pattern

This is the output of : python setup.py install

C:\Users\uidj5318\Desktop\canmatrix-development>python setup.py install C:\Program Files\lib\site-packages\setuptools\dist.py:331: UserWarning: Normalizing '0.6.1-pre' to '0.6.1rc0' normalized_version, running install running bdist_egg running egg_info writing canmatrix.egg-info\PKG-INFO writing dependency_links to canmatrix.egg-info\dependency_links.txt writing entry points to canmatrix.egg-info\entry_points.txt writing requirements to canmatrix.egg-info\requires.txt writing top-level names to canmatrix.egg-info\top_level.txt reading manifest file 'canmatrix.egg-info\SOURCES.txt' writing manifest file 'canmatrix.egg-info\SOURCES.txt' installing library code to build\bdist.win-amd64\egg running install_lib running build_py creating build\bdist.win-amd64\egg creating build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\arxml.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\autosarhelper.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\cancluster.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\canmatrix.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\cmcsv.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\cmjson.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\compare.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\convert.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\copy.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\dbc.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\dbf.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\fibex.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\formats.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\join.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\kcd.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\log.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\sym.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\version.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\xls.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\xlsx.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix\yaml.py -> build\bdist.win-amd64\egg\canmatrix copying build\lib\canmatrix__init.py -> build\bdist.win-amd64\egg\canmatrix byte-compiling build\bdist.win-amd64\egg\canmatrix\arxml.py to arxml.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\autosarhelper.py to autosarhelper.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\cancluster.py to cancluster.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\canmatrix.py to canmatrix.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\cmcsv.py to cmcsv.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\cmjson.py to cmjson.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\compare.py to compare.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\convert.py to convert.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\copy.py to copy.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\dbc.py to dbc.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\dbf.py to dbf.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\fibex.py to fibex.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\formats.py to formats.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\join.py to join.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\kcd.py to kcd.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\log.py to log.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\sym.py to sym.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\version.py to version.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\xls.py to xls.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\xlsx.py to xlsx.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\yaml.py to yaml.cpython-36.pyc byte-compiling build\bdist.win-amd64\egg\canmatrix\init.py to init__.cpython-36.pyc creating build\bdist.win-amd64\egg\EGG-INFO copying canmatrix.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO copying canmatrix.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO copying canmatrix.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO copying canmatrix.egg-info\entry_points.txt -> build\bdist.win-amd64\egg\EGG-INFO copying canmatrix.egg-info\requires.txt -> build\bdist.win-amd64\egg\EGG-INFO copying canmatrix.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO zip_safe flag not set; analyzing archive contents... creating 'dist\canmatrix-0.6.1rc0-py3.6.egg' and adding 'build\bdist.win-amd64\egg' to it removing 'build\bdist.win-amd64\egg' (and everything under it) Processing canmatrix-0.6.1rc0-py3.6.egg Removing c:\program files\lib\site-packages\canmatrix-0.6.1rc0-py3.6.egg Copying canmatrix-0.6.1rc0-py3.6.egg to c:\program files\lib\site-packages canmatrix 0.6.1rc0 is already the active version in easy-install.pth Installing cancompare-script.py script to C:\Program Files\Scripts Installing cancompare.exe script to C:\Program Files\Scripts Installing canconvert-script.py script to C:\Program Files\Scripts Installing canconvert.exe script to C:\Program Files\Scripts Installed c:\program files\lib\site-packages\canmatrix-0.6.1rc0-py3.6.egg Processing dependencies for canmatrix==0.6.1rc0 Searching for future==0.16.0 Best match: future 0.16.0 Processing future-0.16.0-py3.6.egg future 0.16.0 is already the active version in easy-install.pth Installing futurize-script.py script to C:\Program Files\Scripts Installing futurize.exe script to C:\Program Files\Scripts Installing pasteurize-script.py script to C:\Program Files\Scripts Installing pasteurize.exe script to C:\Program Files\Scripts Using c:\program files\lib\site-packages\future-0.16.0-py3.6.egg Finished processing dependencies for canmatrix==0.6.1rc0

This is the output of: pip install -r requirements.txt

Requirement already satisfied: lxml in c:\program files\lib\site-packages (from -r requirements.txt (line 1)) Requirement already satisfied: xlwt in c:\program files\lib\site-packages\xlwt-1.3.0-py3.6.egg (from -r requirements.txt (line 2)) Requirement already satisfied: xlrd in c:\program files\lib\site-packages\xlrd-1.1.0-py3.6.egg (from -r requirements.txt (line 3)) Requirement already satisfied: xlsxwriter in c:\program files\lib\site-packages\xlsxwriter-1.0.2-py3.6.egg (from -r requirements.txt (line 4)) Requirement already satisfied: pyyaml in c:\program files\lib\site-packages (from -r requirements.txt (line 5))

This is the output of: pip freeze

bitstruct==3.5.0 canmatrix==0.6.1rc0 et-xmlfile==1.0.1 freeze==1.0.10 future==0.16.0 jdcal==1.3 lxml==4.1.1 odfpy==1.3.5 openpyxl==2.5.0b1 pyaml==17.10.0 PyYAML==3.12 six==1.11.0 tablib==0.12.1 unicodecsv==0.14.1 xlrd==1.1.0 xlsxwriter==1.0.2 xlwt==1.3.0 xlwt-future==0.8.0

Python version 3.6.3

Any ideas on how to fix this issue?

Thanks

ebroecker commented 6 years ago

could you try an older python-version? 2.2 and 3.5 are tested.

for me it seems, xlwt has problems. You could also try to remove xlwt package.

Andrei1Byte commented 6 years ago

Hello,

On Py 3.5.3 I get this for test.py:

D:\KIT-URI\PyModules\canmatrix-development\test>python test.py arxml -> ['csv', 'dbc', 'dbf', 'json', 'kcd', 'sym', 'xls', 'xlsx', 'xml', 'yaml'] dbc -> ['arxml', 'csv', 'dbf', 'json', 'kcd', 'sym', 'xls', 'xlsx', 'xml', 'yaml'] dbf -> ['arxml', 'csv', 'dbc', 'json', 'kcd', 'sym', 'xls', 'xlsx', 'xml', 'yaml'] json -> ['arxml', 'csv', 'dbc', 'dbf', 'kcd', 'sym', 'xls', 'xlsx', 'xml', 'yaml'] kcd -> ['arxml', 'csv', 'dbc', 'dbf', 'json', 'sym', 'xls', 'xlsx', 'xml', 'yaml'] sym -> ['arxml', 'csv', 'dbc', 'dbf', 'json', 'kcd', 'xls', 'xlsx', 'xml', 'yaml'] Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped Variable type 'string' found and skipped xls -> ['arxml', 'csv', 'dbc', 'dbf', 'json', 'kcd', 'sym', 'xlsx', 'xml', 'yaml'] xlsx -> ['arxml', 'csv', 'dbc', 'dbf', 'json', 'kcd', 'sym', 'xls', 'xml', 'yaml'] yaml -> ['arxml', 'csv', 'dbc', 'dbf', 'json', 'kcd', 'sym', 'xls', 'xlsx', 'xml'] Traceback (most recent call last): File "test.py", line 82, in exit_code = subprocess.call(['diff', '-r', 'reference', 'converted']) File "C:\Python35\lib\subprocess.py", line 247, in call with Popen(*popenargs, **kwargs) as p: File "C:\Python35\lib\subprocess.py", line 676, in init restore_signals, start_new_session) File "C:\Python35\lib\subprocess.py", line 955, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified

[ebroecker] This is ok, because test.py uses diff which is not installed in windows system.

And this for createTestMatrix.py:

D:\KIT-URI\PyModules\canmatrix-development\test>python createTestMatrix.py Traceback (most recent call last): File "createTestMatrix.py", line 7, in import canmatrix.exportall as ex ImportError: No module named 'canmatrix.exportall'

[ebroecker] this is NOT ok. Reason: createTestMatrix.py is heavily outdated. I'll fix this later these days.

pip freeze:

D:\KIT-URI\PyModules\canmatrix-development\test>python -V Python 3.5.3 D:\KIT-URI\PyModules\canmatrix-development\test>pip freeze bitstruct==3.5.0 canmatrix==0.6.1rc0 freeze==1.0.10 future==0.16.0 lxml==4.1.1 pyaml==17.10.0 PyYAML==3.12 six==1.11.0 xlrd==1.1.0 xlsxwriter==1.0.2 xlwt==1.3.0 xlwt-future==0.8.0

ebroecker commented 6 years ago

simply converting should work? canconvert test.dbc test2.dbc

or - if you want in examples:

python convert.py ..\test.dbc test2.dbc

Andrei1Byte commented 6 years ago

Yes simply converting is working (no error).

I tried with python convert.py test.dbc test2.dbc

ebroecker commented 6 years ago

createTestMatrix.py should work again with: 21063ed640b22c9c8c9935c257aac33e1ecadd85

Andrei1Byte commented 6 years ago

The following error is popping up: 'str' object has no attribute 'decode' so I deleted the "decode("utf-8")" for unit="specialCharUnit°$", and "Multi \n Line \n Signal comment with a-umlaut: ä") and now is working.

For test.py is the same behavior.

Andrei1Byte commented 6 years ago

I don't want to create another issue for this question, and I don't know where to address it so I address it here.

@ebroecker : Dose this project(package) supports CAN FD ?

ebroecker commented 6 years ago

CAN FD is now handled in this issue: #115

ebroecker commented 6 years ago

can this issue be closed?

AKstudios commented 2 years ago

I'm getting the same error on Python 3.9.2 and the latest canmatrix commit as of Oct 20, 2022.

raise ValueError("cannot use LOCALE flag with a str pattern") ValueError: cannot use LOCALE flag with a str pattern

I'm also not able to run the test examples: canconvert test.dbc test2.dbc or python convert.py ..\test.dbc test2.dbc

Both of the above return the same error.


UPDATE: The solution here worked for me.

TL;DR: Uninstall xlwt: pip uninstall xlwt and pip uninstall xlwt-future and then specifically reinstall xlwt v1.3.0: pip install 'xlwt==1.3.0'