Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

What OS and which version do you use?

macOS Ventura 13.3.1

How did you installed mysql client library?

brew install mysql pkg-config

Output from pkg-config --cflags --libs mysqlclient

-I/opt/homebrew/Cellar/mysql/8.3.0_1/include/mysql -L/opt/homebrew/Cellar/mysql/8.3.0_1/lib -lmysqlclient

How did you tried to install mysqlclient?

pip install mysqlclient==2.2.4

Output of building mysqlclient

This is not a problem in the build but in the import, seems like it accepts mysql@8.0

ImportError: dlopen(.../venv2/lib/python3.10/site-packages/MySQLdb/_mysql.cpython-310-darwin.so, 0x0002): Library not loaded: /opt/homebrew/opt/mysql@8.0/lib/libmysqlclient.21.dylib
  Referenced from: <3B91F86D-7B78-39AF-95EF-D94B729CE0D5> .../venv2/lib/python3.10/site-packages/MySQLdb/_mysql.cpython-310-darwin.so
  Reason: tried: '/opt/homebrew/opt/mysql@8.0/lib/libmysqlclient.21.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/mysql@8.0/lib/libmysqlclient.21.dylib' (no such file), '/opt/homebrew/opt/mysql@8.0/lib/libmysqlclient.21.dylib' (no such file), '/usr/local/lib/libmysqlclient.21.dylib' (no such file), '/usr/lib/libmysqlclient.21.dylib' (no such file, not in dyld cache)
You must be logged in to vote

If you are using old cache:

$ .venv/bin/pip install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-2.2.4-cp312-cp312-macosx_11_0_arm64.whl
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.2.4

After removing pip cache remove mysqlclient:

$ .venv/bin/pip install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-2.2.4.tar.gz (90 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (pyproject.toml) ... done
  Created wheel f…

Replies: 1 comment · 4 replies

Comment options

Have you cleared pip cache?
Since this library is binding of mysql client C library, you can not reuse wheel after upgrading mysql or mysql-client.

You must be logged in to vote
4 replies
@yanivkrol
Comment options

How do I do a fresh install? I did downgrade to MySQL 8.0 before updating mysqlclient to 2.2.4. but since then I tried uninstalling and installing all these many times, but with no success.

@methane
Comment options

https://pip.pypa.io/en/stable/cli/pip_cache/

$ pip cache list mysqlclient
$ pip cache remove mysqlclient
$ pip cache list mysqlclient
@methane
Comment options

If you are using old cache:

$ .venv/bin/pip install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-2.2.4-cp312-cp312-macosx_11_0_arm64.whl
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.2.4

After removing pip cache remove mysqlclient:

$ .venv/bin/pip install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-2.2.4.tar.gz (90 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (pyproject.toml) ... done
  Created wheel for mysqlclient: filename=mysqlclient-2.2.4-cp312-cp312-macosx_11_0_arm64.whl size=75803 sha256=28739a0fcff8b27c0501b65728772dcf7b25a8bfe5ca005273e7491f77061a08
  Stored in directory: /Users/inada-n/Library/Caches/pip/wheels/20/6f/c3/3b23bb01988b1c0bea0668e2116315ce43ced2179724ab593e
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.2.4

You can see mysqlclient-2.2.4.tar.gz is still cached and reused, but built wheel is not used and new binary is built during install.

Answer selected by yanivkrol
@yanivkrol
Comment options

Great it works now ,thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.