c_formatter_42
c_formatter_42 copied to clipboard
TypeError when using c_formatter_42 in Python 3.11.6
-
I've installed c_formatter_42 using pip3 install c-formatter-42 in Python 3.11.6. The installation was successful without any errors.
-
However, when I try to use the package, I get a TypeError with the following traceback:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/opt/homebrew/lib/python3.11/site-packages/c_formatter_42/__main__.py", line 18, in <module>
from c_formatter_42.run import run_all
File "/opt/homebrew/lib/python3.11/site-packages/c_formatter_42/run.py", line 14, in <module>
from c_formatter_42.formatters.clang_format import clang_format
File "/opt/homebrew/lib/python3.11/site-packages/c_formatter_42/formatters/clang_format.py", line 21, in <module>
DATA_DIR = Path(c_formatter_42.data.__file__).parent
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py", line 871, in __new__
self = cls._from_parts(args)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py", line 509, in _from_parts
drv, root, parts = self._parse_args(args)
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py", line 493, in _parse_args
a = os.fspath(a)
^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not NoneType
42-c-format: Please read README and check requirements.
- The error seems to come from the
c_formatter_42
package's source code. It's trying to get the__file__
attribute of thec_formatter_42.data
module, but this attribute seems to beNone
. - I'm using macOS and Visual Studio Code as my code editor. I've followed all the setup instructions in the README, including setting the correct Python interpreter in VS Code and installing the
keyhr.42-c-format
extension. - I've checked the Python version, reinstalled the package, and read the README, but none of these steps have resolved the issue.
Can you please help me understand what's going wrong?
It's weird, with almost the same version of Python, I have no problem running it.
❯ python
Python 3.11.5 (main, Aug 24 2023, 15:23:30) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import c_formatter_42.data
>>> print(c_formatter_42.data.__file__)
/.../c_formatter_42/c_formatter_42/data/__init__.py
❯ echo 'int main() { return 0; }' | c_formatter_42
int main(void)
{
return (0);
}