OpenCC: Cannot import OpenCC using Python on macOS Ventura

Hi everyone,

Problem Description I get following error when I am running import opencc with Python: OSError: dlopen(libopencc.so.1, 0x0006): tried: 'libopencc.so.1' (no such file).

Steps to Reproduce I am using macOS Ventura 13.1, and Mamba with a virtual environment to use Python (version 3.10.8).

I first installed OpenCC via Homebrew running brew install opencc, and then installed OpenCC with pip in my virtual environment running pip install opencc. The first thing I noticed is that pip is installing OpenCC version 0.2 instead of the latest version (1.1.6 up to now). I also tried to reinstall OpenCC using this file and using brew install opencc.rb, but it led to the same result.

I checked that Homebrew installed correctly OpenCC on my computer: running which opencc, I get the following path: /opt/homebrew/bin/opencc.

I suppose there is a confusion between opencc and libopencc.so.1 libraries, but I am currently unable to fix this problem.

I hope someone could help!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (5 by maintainers)

Most upvoted comments

That’s how I install Python opencc on Apple M1.

My environment:

  • Apple M1 13.1
  • Homebrew 3.6.20-146-g4b3d64d
  • Python 3.10.9
brew install opencc
> which opencc
/opt/homebrew/bin/opencc
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -U pip setuptools wheel

git clone https://github.com/BYVoid/OpenCC.git
cd OpenCC
python3 setup.py build_ext
python3 -m pip install .
> python3 -c 'import opencc; print(opencc.__version__);'
1.1.6
> python3 -m pip list
Package    Version
---------- -------
OpenCC     1.1.6
pip        22.3.1
setuptools 67.0.0
wheel      0.38.4