PyCQA / docformatter

Formats docstrings to follow PEP 257
https://pypi.python.org/pypi/docformatter
MIT License
530 stars 61 forks source link

ImportError: dlopen(/Users/glennjocher/.cache/pre-commit/repofadve4nf/py_env-python3.11/lib/python3.11/site-packages/charset_normalizer/md.cpython-311-darwin.so, 0x0002) #267

Closed glenn-jocher closed 10 months ago

glenn-jocher commented 11 months ago

The issue seems related to a mismatch in the architecture of the compiled Python package and the architecture of your system. Your system is running on arm64, but the charset_normalizer package appears to have been compiled for x86_64.

fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
check for case conflicts.................................................Passed
check docstring is first.................................................Passed
fix double quoted strings................................................Passed
detect private key.......................................................Passed
Upgrade code.............................................................Passed
Sort imports.............................................................Passed
YAPF formatting..........................................................Passed
MD formatting........................................(no files to check)Skipped
PEP8.....................................................................Passed
codespell................................................................Passed
docformatter.............................................................Failed
- hook id: docformatter
- exit code: 1
Traceback (most recent call last):
  File "/Users/glennjocher/.cache/pre-commit/repofadve4nf/py_env-python3.11/bin/docformatter", line 5, in <module>
    from docformatter.__main__ import main
  File "/Users/glennjocher/.cache/pre-commit/repofadve4nf/py_env-python3.11/lib/python3.11/site-packages/docformatter/__init__.py", line 36, in <module>
    from .encode import Encoder  # isort: skip # noqa F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/glennjocher/.cache/pre-commit/repofadve4nf/py_env-python3.11/lib/python3.11/site-packages/docformatter/encode.py", line 33, in <module>
    from charset_normalizer import from_path  # pylint: disable=import-error
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/glennjocher/.cache/pre-commit/repofadve4nf/py_env-python3.11/lib/python3.11/site-packages/charset_normalizer/__init__.py", line 24, in <module>
    from .api import from_bytes, from_fp, from_path, is_binary
  File "/Users/glennjocher/.cache/pre-commit/repofadve4nf/py_env-python3.11/lib/python3.11/site-packages/charset_normalizer/api.py", line 5, in <module>
    from .cd import (
  File "/Users/glennjocher/.cache/pre-commit/repofadve4nf/py_env-python3.11/lib/python3.11/site-packages/charset_normalizer/cd.py", line 14, in <module>
    from .md import is_suspiciously_successive_range
ImportError: dlopen(/Users/glennjocher/.cache/pre-commit/repofadve4nf/py_env-python3.11/lib/python3.11/site-packages/charset_normalizer/md.cpython-311-darwin.so, 0x0002): tried: '/Users/glennjocher/.cache/pre-commit/repofadve4nf/py_env-python3.11/lib/python3.11/site-packages/charset_normalizer/md.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/glennjocher/.cache/pre-commit/repofadve4nf/py_env-python3.11/lib/python3.11/site-packages/charset_normalizer/md.cpython-311-darwin.so' (no such file), '/Users/glennjocher/.cache/pre-commit/repofadve4nf/py_env-python3.11/lib/python3.11/site-packages/charset_normalizer/md.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))

Environment

Ultralytics YOLOv8.0.198 🚀 Python-3.11.2 torch-2.1.0 CPU (Apple M2)
Setup complete ✅ (8 CPUs, 16.0 GB RAM, 250.8/460.4 GB disk)

OS                  macOS-14.0-arm64-arm-64bit
Environment         Darwin
Python              3.11.2
Install             git
RAM                 16.00 GB
CPU                 Apple M2
CUDA                None

matplotlib          ✅ 3.8.0>=3.3.0
numpy               ✅ 1.26.1>=1.22.2
opencv-python       ✅ 4.8.1.78>=4.6.0
pillow              ✅ 10.0.1>=7.1.2
pyyaml              ✅ 6.0.1>=5.3.1
requests            ✅ 2.31.0>=2.23.0
scipy               ✅ 1.11.3>=1.4.1
torch               ✅ 2.1.0>=1.8.0
torchvision         ✅ 0.16.0>=0.9.0
tqdm                ✅ 4.66.1>=4.64.0
pandas              ✅ 2.1.1>=1.1.4
seaborn             ✅ 0.13.0>=0.11.0
psutil              ✅ 5.9.6
py-cpuinfo          ✅ 9.0.0
thop                ✅ 0.1.1-2209072238>=0.1.1

Reproduce

Clone the https://github.com/ultralytics/ultralytics repo in PyCharm, run pip install -e '.[dev]' and then run push to your branch using PyCharm, and the error will appear.

weibullguy commented 11 months ago

I can't reproduce the problem. This is likely any issue with your environment or pypi, but unlikely a docformatter issue.

PaulWestenthanner commented 10 months ago

I just ran into the same problem (I think).

I installed docformatter via pip into a conda environment using python 3.11 on an Ubuntu 20.4 LTS machine.

(orca_new) westentp@rpeuwprlc0013:~/projects/orca$ docformatter --help
Traceback (most recent call last):
  File "/home/users/westentp/anaconda3/envs/orca_new/bin/docformatter", line 5, in <module>
    from docformatter.__main__ import main
  File "/home/users/westentp/anaconda3/envs/orca_new/lib/python3.11/site-packages/docformatter/__init__.py", line 36, in <module>
    from .encode import Encoder  # isort: skip # noqa F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/users/westentp/anaconda3/envs/orca_new/lib/python3.11/site-packages/docformatter/encode.py", line 33, in <module>
    from charset_normalizer import from_path  # pylint: disable=import-error
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/users/westentp/anaconda3/envs/orca_new/lib/python3.11/site-packages/charset_normalizer/__init__.py", line 23, in <module>
    from charset_normalizer.api import from_fp, from_path, from_bytes, normalize
  File "/home/users/westentp/anaconda3/envs/orca_new/lib/python3.11/site-packages/charset_normalizer/api.py", line 10, in <module>
    from charset_normalizer.md import mess_ratio
  File "charset_normalizer/md.py", line 5, in <module>
ImportError: cannot import name 'COMMON_SAFE_ASCII_CHARACTERS' from 'charset_normalizer.constant' (/home/users/westentp/anaconda3/envs/orca_new/lib/python3.11/site-packages/charset_normalizer/constant.py)
PaulWestenthanner commented 10 months ago

Update:

conda install -c conda-forge charset-normalizer solved it for me as suggested here: https://stackoverflow.com/questions/74535380/importerror-cannot-import-name-common-safe-ascii-characters-from-charset-nor

glenn-jocher commented 10 months ago

Closing as I'm not longer receiving this error.