. Advertisement .
..3..
. Advertisement .
..4..
When you try to automate anything in this tool, you get the following error message: “undefined symbol: _PyUnicode_DecodeUnicodeEscape“. Don’t be too concerned. This article will assist all readers in resolving the issues they are experiencing with this well-known program.
When Would The Error “undefined symbol: _PyUnicode_DecodeUnicodeEscape” Occur?
You are attempting to import ast3 from typed ast, but you get the following error.
ImportError: /usr/lib/python3/dist-packages/typed_ast/_ast3.cpython-39-x86_64-linux-gnu.so: undefined symbol: _PyUnicode_DecodeUnicodeEscape
In another case, on Python 3.9.8, you are importing the module as installed from PyPI (x86 64 architecture) results in the following exception:
Traceback (most recent call last):
File "/home/runner/.cache/pre-commit/repo8e93dzwn/py_env-python3/bin/black", line 5, in <module>
from black import patched_main
File "/home/runner/.cache/pre-commit/repo8e93dzwn/py_env-python3/lib/python3.9/site-packages/black/__init__.py", line 52, in <module>
from typed_ast import ast3, ast27
File "/home/runner/.cache/pre-commit/repo8e93dzwn/py_env-python3/lib/python3.9/site-packages/typed_ast/ast3.py", line 40, in <module>
from typed_ast import _ast3
ImportError: /home/runner/.cache/pre-commit/repo8e93dzwn/py_env-python3/lib/python3.9/site-packages/typed_ast/_ast3.cpython-39-x86_64-linux-gnu.so: undefined symbol: _PyUnicode_DecodeUnicodeEscape
This error appears to be a bug in Python 3.9.7 and Python 3.9.8.
Top Solutions For “undefined symbol: _PyUnicode_DecodeUnicodeEscape” Error
You can use the syntax described below to resolve this fundamental issue.
Method 1: Upgrade the typed-ast
In your case, the issue was resolved by using the most recent version of typed-ast. You need to use this command.
pip install typed-ast --upgrade
Method 2: Use this code
Using this code is a solution for you to resolve your problem.
diff --git a/ast3/Python/ast.c b/ast3/Python/ast.c
index cfca73f..93da89c 100644
--- a/ast3/Python/ast.c
+++ b/ast3/Python/ast.c
@@ -56,6 +56,8 @@ _PyBytes_DecodeEscape(const char *s,
return PyBytes_DecodeEscape(s, len, errors, unicode, recode_encoding);
}
+#endif
+
PyObject *
_PyUnicode_DecodeUnicodeEscape(const char *s,
Py_ssize_t size,
@@ -66,7 +68,6 @@ _PyUnicode_DecodeUnicodeEscape(const char *s,
return PyUnicode_DecodeUnicodeEscape(s, size, errors);
}
-#endif
static int validate_stmts(asdl_seq *);
static int validate_exprs(asdl_seq *, expr_context_ty, int);
Now your problem will be solved.
Method 3: Upgrade Black to the most recent version, 21.10b0
Besides two methods presented above, there is another method for you to resolve the error “undefined symbol: _PyUnicode_DecodeUnicodeEscape”.
The original issue is a Python Black pipeline failure.Black is pegged to an outdated version which no longer works with Python 3.9.8, so it fails. Upgrading Black to the most recent version, 21.10b0, is a fantastic solution for you to handle your problem.
Using the most recent typed-ast version >=1.5.0 also seems to be effective.
For instance: pip install typed-ast --upgrade
Conclusion
In conclusion, the approaches presented above are straightforward solutions to the aforementioned major error: “undefined symbol: _PyUnicode DecodeUnicodeEscape“. Please leave your other questions in the comments section so that our team can look them over. we hope you all have a productive day with your Python tool.
Read more
→ Solutions For React Native Build Error: “Undefined symbols for architecture x86_64”
Leave a comment