PyCG
PyCG copied to clipboard
SyntaxError -> can't load unicodedata module
When I was using PyCG to resolve tensorflow, the following error occurred:
SyntaxError: (unicode error) \N escapes not supported (can't load unicodedata module)
More precisely, it looks like:
Traceback (most recent call last): File "/home/allen/anaconda3/envs/python3.9/bin/pycg", line 8, in
sys.exit(main()) File "/home/allen/anaconda3/envs/python3.9/lib/python3.9/site-packages/pycg/main.py", line 79, in main cg.analyze() File "/home/allen/anaconda3/envs/python3.9/lib/python3.9/site-packages/pycg/pycg.py", line 155, in analyze self.do_pass(PreProcessor, True, File "/home/allen/anaconda3/envs/python3.9/lib/python3.9/site-packages/pycg/pycg.py", line 148, in do_pass processor.analyze() File "/home/allen/anaconda3/envs/python3.9/lib/python3.9/site-packages/pycg/processing/preprocessor.py", line 375, in analyze self.visit(ast.parse(self.contents, self.filename)) File "/home/allen/anaconda3/envs/python3.9/lib/python3.9/ast.py", line 50, in parse return compile(source, filename, mode, flags, File "/home/allen/DL_API/Static_Analysis/3rd_lib/tensorflow-master/tensorflow/tools/docs/generate2.py", line 121 has_gradient = "\N{HEAVY CHECK MARK}\N{VARIATION SELECTOR-16}" ^ SyntaxError: (unicode error) \N escapes not supported (can't load unicodedata module)
I'm curious about the cause of the above error. Do you have any idea?
Hi @QingYiSun, I've seen this error before on some packages, and I have gathered that this is a random error depending on the distribution that one uses (source). Appreciate your input as I keep looking for workarounds.
Thanks for your hard work~
Most likely because your code is running on Apple M1. Consider changing to the Linux platform.
I am also seeing this on linux (Arch with Python 3.11.3).
The source of the error is: https://github.com/python/cpython/blob/9e6590b0978876de14587f528a09632b8879c369/Objects/unicodeobject.c#L6031-L6038
pycg fails, but I can use ast.parse
directly with the file in question.
Are you doing something that is modifying the normal import machinery?